Addressing this would be very helpful for me as well. I have “tags” and “topics” (which are [[links]]) in YAML frontmatter and I’d love to be able to click them in both edit and preview modes.
For all of those who are so excited about YAML front-matter blocks, could you share some use cases? (Perhaps under “Share & showcase”.) Since so much of the point of Obsidian seems to be the linking, I’m curious where the advantages lie in excluding key links within a front-matter block.
The current idea is to use the YAML block for dev\plugins metadata. We are finalizing this decision.
Users should not really use the YAML metadata directly. If users want to use a
frontmatter, they can do so outside the YAML block, i.e.
--- YAML metadata --- your frontmatter --- main text
--- YAML metadata --- # your frontmatter bla bla bla --- main text
Good to know. Thanks.
I’m not sure about what is officially planned, but I’m excited to have some sort of custom meta data that can then be used to display lists of files in a table based on that meta data.
For example, if I have all of my daily notes in a folder, I could have a meta data field of Day-(day of week)
then I could view all of the daily notes and sort/filter all notes written on a Monday.
Tracking multiple fields would also allow for some data analysis of looking at days where I do well on my habits/goals and see what factors correlate the most, etc.
Just want to let everyone know that YAML frontmatter is typically removed from the source code when rendering, and the variables stored are used as metadata for whichever app is reading it.
Right now we aren’t using it to store anything, but in the future, plugins would be able to access a built-in way of making decisions based on the data inside the frontmatter.
This may mean showing some UI that contains data, such as tags showing as a tag list on top of the file, or links that render as “related” somewhere else. That would be entirely customizable by the plugin and out of our control.
In the meantime, since this metadata is almost always hidden from view in other apps, we’ll be doing the same.
I do recognize the use case for some kind of user-defined front matter that’s different from what “markdown frontmatter” usually means. You can (and should) just use plain Markdown properly and do it like this:
tags: #mytag links: [[My other file]] --- Body content
This is fair enough. Now I will try to remove the start of the YAML block from many of my notes.
Can anyone help me with regex searching, so I can be sure to get all my notes?
I want to search for the string
--- but only if it is the very first set of characters in the document. Otherwise my search will return every horizontal line I have ever made.
This makes sense. Especially now that I’ve been playing around with publishing some of these markdown files.
Does this mean we wont get a sorting of files through YAML metadata like dates and such, or is it well within that realm of possibility?
I am not sure exactly what you mean.
However, I can see a plugin implementing a sort by date and using a date stored in the YAML block.
Please, back up your notes. I can’t tell how many times I screwed up while playing with regex on multiple files at once.
I believe this will do the trick:
I use VS Code and recommend it, but it should work on other editors.
That’s what I meant. I was interested in YAML, mainly for sorting purposes (among other benefits to YAML). I appreciate sorting by the date in YAML, rather than by edit time. I would have taken a sort function by creation date, but with respect to migration, I think that would screw some things up, so yeah, thats why I like the sorting by YAML idea.
Thanks, that worked great!
I would also be happy if YAML matter could nonetheless remain linkable. I use it to essentially attach file-level metadata to a note, such as major tags, authors for books, etc., as I don’t really want this information to be part of the final note, and yet I want it to be discoverable by search, the graph etc.
I’m trying to figure out how to use frontmatter in my notes.
How do you use it?
On the top of a note, use the syntax:
--- tags: aliases: whatever else you want to write: ---
to indicate frontmatter. Note that the main purpose of frontmatter is to give plugins a place to store user-readable metadata.
See the recent release notes on how to use
aliases. Note that these features are only available in Insider builds at this moment.
Do you have examples of how tags and aliases are used?
I just added the functionality of updating a frontmatter in the “Markdown Prettifier” plugin. Perhaps I should take that feature out…
@WhiteNoise recommended in August to use this format
--- YAML metadata --- your frontmatter --- main text
After all the changes in the meantime, is this still recommended, or I could put my custom attributes there like in ryan’s example above?
I have the same question. I also see (I think above, but I’ve got so many tabs open on this subject right now) that some will encapsulate their title not in quote marks
" but double brackets
[[ so that, I assume, they update with the note title changes. This works well, but it does not work in the YAML header either. Thoughts?
you can add your custom attributes in the YAML frontmatter but:
- They MUST be in proper yaml format.
- If an attribute is not handled by obsidian or plugin, it will be ignored. But still has to be YAML format.
- There is no support (yet) for adding a linked mention to another note, that is, if NoteA has this frontmatter:
--- links: [[NoteB]], [[NoteC]] ---
It will not work. NoteA will not appear as a linked mention (backlink) in NoteB and NoteC.
- The YAML frontmatter is not scanned when searching for unlinked mentions (and probably never will be). That is, if NoteA has this frontmatter:
--- connections: [NoteB, NoteC] ---
NoteA will not appear as an unlinked mention in NoteB and NoteC.
I would like to add that if at some point we add support for linking other notes in the YAML block, it will be specific and limited to a YAML attribute, like
related: . But it still won’t be possible to add linked mentions in other attributes.
So if this is your intent, I think you are still better off with you own frontmatter in the document and not in the YAML block.