Include / show note links in yaml frontmatter (v0.8.5)

Include / show note links in yaml frontmatter (v0.8.5)

Problem

I was using note links in the yaml part to make references to other notes but they doesn’t work anymore in obs 0.8.5.

I don’t see the links to my other notes that were in the front matter in the graph view nor in the backlinks.

Another result of this is that my old links that were in the front matter don’t update when I rename them.

Feature request

A possible solution would be to have an options page for yaml front matter where a toggleable option to enable note links is present.

When this option is enabled:

  • links syntax is highlighted in edit mode
  • links are displayed as such in preview mode
  • links are detected in related features like graph view and backlinks

Example

Here is an example of a front-matter of mine:

---
id: 20200822115642
title: [[My Super Note]]
date: [[2020-08-22]]
language: 🇺🇸
brain:
- [[2020-08-22 - Brain Dump#13 37]]
references:
- Obsidian: A knowledge base that works on local Markdown files. (n.d.). Retrieved June 24, 2020, from https://obsidian.md/
- [[Another source note]]
---

# My Super Note

Content
...

Temporary solution

For now, if you have the same problem as me you can start the yaml front matter part with 4 ‘-’ like so:

----

id: 20200822115642
title: [[My Super Note]] <-- working

---

# My Super Note

Somewhat related

11 Likes

Front matter tags don’t show in tag pane, or search either.
Ditto for code blocks.

I often don’t want tags visible in preview.

3 Likes

Indeed they aren’t in the tag pane.
But tags are actually displayed in the search pane even if they are in a code block.

Are you talking about Editor / Show frontmatter option that hide the frontmatter ?
Or are you talking about you not wanting to see a tag as a link in code blocks ?

The request is actually to not treat the yaml frontmatter as a code block. I would also don’t want links and tags in other code blocks.

Maybe a special code block syntax (like the mermaid one) used internally by obsidian would do the trick to accept tags and links in the yaml header.

1 Like

I do the same. I use my yaml frontmatter for tags and related topics (backlinks). With this feature turned on, none of my tags or backlinks within the yaml block work. I would expect it to. Or at least have an option to enable/disable it.

I’m pretty new to this. I assume that is what we would use the yaml frontmatter for (tags, etc.). If there is a better way, please let me know.

2 Likes

I’m the OP of the bug report, and this is a major issue for me. I also use tags and links in my front-matter, and I have been using custom delimiters to avoid Obsidian formatting and will continue to do so.

1 Like

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.

1 Like

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.

3 Likes

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

or

---
YAML metadata
---

# your frontmatter
bla bla bla

--- 
main text
3 Likes

Good to know. Thanks.

1 Like

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.

2 Likes

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
5 Likes

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.

:warning: Please, back up your notes. I can’t tell how many times I screwed up while playing with regex on multiple files at once. :warning:

I believe this will do the trick:

Find: ^(?<![\s\S\r])---\n
Replace:

I use VS Code and recommend it, but it should work on other editors.

2 Likes

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.

4 Likes

Hello!

I’m trying to figure out how to use frontmatter in my notes.

How do you use it?

1 Like