Hacking Obsidian: Frontmatter and Templater ![rw-book-cover](https://miro.medium.com/v2/resize:fit:833/1*_WA1wh2J7_wZjj5arXBzjg.jpeg) ## Metadata - Author: [[TfTHacker]] - Full Title: Hacking Obsidian: Frontmatter and Templater - Category: #articles - Document Note: --- tags: - #obsidian - #templater - #frontmatter Author: TfTHacker Source: Medium article Reference: https://medium.com/obsidian-observer/hacking-obsidian-frontmatter-and-templater-f4912a689cdc date created: {{date:YYYY-MM-DD}} {{time:HH:mm}} --- # Title: Hacking Obsidian: Frontmatter and Templater ## Table of Contents: - 📝 Summary (#-📝-summary) - 📖 Main Content (#-📖-main-content) - 🗒️ Notes (#-🗒️-notes) - 📖 References (#-📖-references) - 🗣️ Paraphrase (#-🗣️-paraphrase) - 📰 Newsletter (#-📰-newsletter) - ✅ Action Items (#-✅-action-items) - 🧪 Hypotheses (#-🧪-hypotheses) - 📊 Methodology (#-📊-methodology) - ❓ Questions (#-❓-questions) - 🔮 Future Research (#-🔮-future-research) - 💡 Implications (#-💡-implications) - 🧠 Learning Styles Assessment (#-🧠-learning-styles-assessment) - 📊 Accessibility Assessment (#-📊-accessibility-assessment) - 🌍 DEIB Assessment (#-🌍-deib-diversity-equity-inclusion-and-belonging-assessment) - ✅ Logical validity (#-✅-logical-validity) - 🔍 DARVO Analysis Prompt (#-🔍-darvo-analysis-prompt) - 🔍 SEO Evaluation (#-🔍-seo-evaluation) - 🎯 Conclusion (#-🎯-conclusion) ### References: - TfTHacker, “Hacking Obsidian: Frontmatter and Templater,” Medium, 2023-05-25. https://medium.com/obsidian-observer/hacking-obsidian-frontmatter-and-templater-f4912a689cdc ## 📝 Summary: The article explains a simple, practical hack to prevent Obsidian and other plugins from interpreting frontmatter contained within Templater templates as real metadata. Instead of using the standard triple-dash YAML delimiters (---), you wrap those dashes inside Templater evaluation tags <% and %>. This keeps the “frontmatter” inert while the file is a template so it doesn’t pollute search, metadata panels, or other plugin logic. When the template is executed, Templater removes the <% %> wrappers and outputs valid YAML frontmatter in the newly created note. Key idea quoted: “To prevent Obsidian from detecting metadata in a template... use a <% at the beginning and a %> at the end of the line... The <% and %> commands are only interpreted by Templater... Obsidian treats the information as regular text instead of frontmatter.” ## 📖 Main Content: The problem: - Templates in Obsidian are blueprints used to keep notes consistent for recurring types (meetings, articles, flashcards, languages). - Many users employ the Templater plugin to create advanced, dynamic templates. - Issue: If a template contains YAML frontmatter demarcated by --- at the top, Obsidian and other plugins may read it as real metadata. That can cause: - Template files appearing in metadata queries. - Incorrect counts in dashboards. - Unwanted fields polluting global metadata. The hack: - Replace leading and trailing YAML delimiters (---) with Templater tags: `<% --- %>` at the start and `<% --- %>` at the end of the frontmatter block. - Why it works: - Obsidian recognizes frontmatter only when it encounters standalone triple dashes at the very top. - Wrapping the dashes in `<% %>` prevents Obsidian from seeing actual raw `---`. It’s treated as plain text during template storage. - When you instantiate the template, Templater evaluates and removes the `<% %>`, leaving real `---` so the new note has valid frontmatter. Practical example: - A flashcard template with fields like: - type: flashcard - subType: language - Keep those fields inside the pseudo-frontmatter (delimited by `<% --- %>` and `<% --- %>`) to avoid metadata bleed in the template file. - On use, the resulting note contains valid YAML at the top, enabling downstream plugins to function correctly on actual notes only. Considerations: - This is a pragmatic workaround rather than a core feature toggle. - It preserves template readability and keeps metadata logic clean across your vault. ### 🗒️ Notes - Templates in Obsidian - Speed up note creation; ensure consistency. - Common for meetings, articles, personal info, flashcards. - Templater plugin - Enables advanced templating, dynamic fields, and logic. - Frontmatter basics - YAML block at the top of a note, between `---` lines. - Used by Obsidian and plugins to read metadata. - Problem statement - Templates with `---` can be misread as real notes’ metadata. - Side effects: query pollution, dashboard noise, incorrect filters. - The `<% --- %>` solution - Use `<% --- %>` instead of raw `---` at the start. - Use `<% --- %>` instead of raw `---` at the end. - Obsidian treats content as plain text in the template file. - On insertion, Templater removes `<% %>`, produces valid YAML. - Benefits - Clean separation: templates aren’t “real” notes to Obsidian. - No accidental indexing of template metadata. - Maintains proper YAML in instantiated notes. - Scope and limitations - Requires Templater processing to realize valid frontmatter. - If template file is opened without applying Templater, the “frontmatter” won’t be active. ## 📖 References: - TfTHacker. “Hacking Obsidian: Frontmatter and Templater.” https://medium.com/obsidian-observer/hacking-obsidian-frontmatter-and-templater-f4912a689cdc ## 🗣️ Paraphrase: 1) Original sense: The problem with frontmatter in templates is that Obsidian and other plugins see it as real metadata. You may not want that because templates are blueprints, not actual notes. - Paraphrase: When you include normal YAML frontmatter in a template, Obsidian assumes it belongs to a genuine note. That misclassification can confuse plugins and queries. Since a template isn’t a finished note, you typically don’t want its fields counted as part of your vault’s live metadata. 2) Original sense: Replace the `---` fences with `<% --- %>` so Obsidian ignores them in the template. When the template is used, Templater strips the tags and restores valid YAML. - Paraphrase: Wrap the opening and closing YAML dashes inside Templater tags. This keeps the “frontmatter” inert inside the template file. On insertion, Templater evaluates and removes the wrappers, leaving proper frontmatter in the resulting note. ## 📰 Newsletter: This week in web dev and WordPress: a tiny-but-mighty Obsidian tip with big implications for your content workflows. If your templates use YAML frontmatter, Obsidian may treat those as real metadata—skewing dashboards and queries. The fix is delightfully simple: wrap your frontmatter fences inside Templater tags like `<% --- %> ... <% --- %>`. Obsidian ignores the template’s frontmatter, but when you create a new note, Templater outputs valid YAML. Cleaner metadata, saner searches. While you’re polishing developer docs, check recent updates across the ecosystem—Core performance improvements, new Hooks in popular plugins, and contributor sprints ramping up ahead of the next minor release. Community highlights: onboarding cohorts are open; if you’re looking to sharpen PHP/JS skills and contribute, now’s your moment. New plugins worth a look: improved site health dashboards and smarter image lazy-loading. Pro tip: apply the Obsidian trick to keep your internal knowledge base tidy while you iterate on content models. Reference: “Hacking Obsidian: Frontmatter and Templater” by TfTHacker. ## ✅ Action Items: Strategic prompt for aligning this article with open-source advocacy, contributor engagement, and education (OSPO trajectory): - Map to education: - Use this technique in internal curriculum notes to prevent template metadata from polluting learning repositories. - Create a lesson showing “data hygiene in docs” using the `<% --- %>` pattern as an example of source-of-truth preservation. - Contributor onboarding: - Standardize contributor issue/PR templates with “inert until instantiated” sections to prevent bots from misreading placeholders. - Document a “template hygiene” checklist for project repos and knowledge bases. - Open-source sustainability: - Emphasize metadata integrity as a maintainability practice: clean dashboards → better decisions → sustainable governance. - Encourage plugin authors to offer “ignore template metadata” options; open an RFC/model issue. - OSPO leadership: - Policy: define metadata conventions for docs/templates across teams (YAML fences, processing tags, validation). - T - Summary: Templates in Obsidian serve as pre-designed blueprints, streamlining the process of creating notes by eliminating the need to start from scratch every time and maintaining consistency. However, one common issue when utilizing Templater is that frontmatter in a template can be mistakenly recognized as metadata by other tools. To prevent this, the hack is to use <% at the beginning and %> at the end of the line instead of enclosing the frontmatter metadata with three dashes ( ---), so that Obsidian treats the information as regular text instead of frontmatter. Ultimately, this hack allows you to maintain a properly formatted document template without frontmatter that’s processed. - URL: https://medium.com/obsidian-observer/hacking-obsidian-frontmatter-and-templater-f4912a689cdc ![](https://miro.medium.com/v2/resize:fit:1400/1*_WA1wh2J7_wZjj5arXBzjg.jpeg)A note with frontmatter metadata. Templates are an important part of Obsidian vaults. > Templates serve as pre-designed blueprints, streamlining the process of creating notes by eliminating the need to start from scratch every time. > > Templates are not just efficient ways of creating frequent note types, but help you remain consistent. For instance, you may have templates for meetings, articles, or personal information that you frequently use. Many Obsidian users take advantage of [Templater](https://obsidian.md/plugins?id=templater-obsidian), a plugin designed for crafting more advanced templates. One common issue when utilizing Templater is that frontmatter in a template can be mistakenly recognized as metadata by other tools. > Frontmatter is a way of adding metadata to my notes. > > For example, in the note, as shown in the image at the beginning of this article, we see a flashcard note where I have defined frontmatter. * **type** of note, which is a flashcard * **subType** which is for learning a language. One common issue when utilizing Templater is that frontmatter in a template can be mistakenly recognized as metadata by Obsidian and other plugins. However, you may not want your template to be visible to these plugins since templates are merely blueprints, not actual notes. ### The <%---%> Hack To prevent Obsidian from detecting metadata in a template, try this straightforward hack. Instead of enclosing the frontmatter metadata with three dashes ( ---), use a **<%** at the beginning and a **%>** at the end of the line. So the template now looks like this: ![](https://miro.medium.com/v2/resize:fit:1400/1*zg07_ZZl05c2d5KKxFB8FA.jpeg)Hack to prevent the template to be processed as having frontmatter. The <% and %> commands are only interpreted by Templater. By not using three standalone dashes, Obsidian treats the information as regular text instead of frontmatter. Ultimately, this hack allows you to maintain a properly formatted document template without frontmatter that’s processed. Of course when you use the template later, the <% and %> are removed by Templater and the new document now has valid frontmatter. *Did you enjoy this useful information? Please consider signing up to email notifications when I publish an article:* [*https://bit.ly/medium-email-sub*](https://bit.ly/medium-email-sub)*.* *Help support all your favorite writers using my referral link:* [*https://bit.ly/o42-medium*](https://bit.ly/o42-medium) *or buy me a coffee at:* [*https://bit.ly/o42-kofi*](https://bit.ly/o42-kofi)*. Your support is appreciated!*, Hacking Obsidian: Frontmatter and Templater, TfTHacker, 01h1vnges2k342f1b8renj581g.