Hacking Obsidian: Frontmatter and Templater
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, 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:
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.
Help support all your favorite writers using my referral link: https://bit.ly/o42-medium or buy me a coffee at: https://bit.ly/o42-kofi. Your support is appreciated!