Tags and frontmatter

I have a use-case where I am using Obsidian to write the content that will be presented via mkdocs which has caused some ‘interesting’ problems due to differences in how they both interpret the files. Tags are one of those areas.

The problem is that mkdocs doesnt have any support whatsoever for hashtags. You cant even search for them in the site. It does however have a plugin which supports them when in this format:

---
tags:
  - tag1
  - tag2
  - tagN
---

In messing around, I found that Obsidian kinda sorta understands this because it will suggest these names when typing a hashtag. They however do not show in Obsidian’s tag list or work as a tag search.

I did however find that while hashtags in the YAML frontmatter also dont appear in the tag list, they are searchable. That has lead me to using this less than ideal but workable model:

---
tags: #some_tag_not_shown_in_mkdocs #some_other_tag_not_shown_in_mkdocs
  - tag1 #tag1
  - tag2 #tag2
  - tagN #tagN
---

Re: #some_tag_not_shown_in_mkdocs: Ive found that there are times its kinda useful to have tags that are usable only in Obsidian that dont appear in the mkdocs generated page.

Within the YAML frontmatter, at some point would it be possible for Obsidian to fully support:

  1. hashtags, and
  2. YAML lists of tags?

This combo would permit a cleaner page render via mkdocs, eliminate duplicate data, and provide full tag support in Obsidian (inc Tag Wrangler which I find immensely helpful).

Just type #your_tag to get the benefit of completion, and then use one of the plugins that automatically removes the # when you save the file.
Several plugins do this, e.g. GitHub - platers/obsidian-linter: An Obsidian plugin that formats and styles your notes with a focus on configurability and extensibility.

Thank you for the suggestion but that doesnt resolve my request. By removing the hash, then it isnt possible to use Obsidian’s tag search. I need to be able to do that which is why I included them.

Beyond the reasons I provided above, Id much prefer to be able to save my tags and etc in the YAML frontmatter. The %% block for hiding text isnt supported elsewhere (or at least not in GitLab and mkdocs) and Obsidian justifiably ignores tags in <!-- HTML comments -->. IMHO, the frontmatter block is the ideal place for storing all the metadata.

That’s not right. Tags in the frontmatter in the field tags: are indexed by Obsidian regardless of the hash. Try it

1 Like

I did. Hence what I wrote in my original post

Searching tag:tag1 or tag:#tag1 works for tags in YAML. If you’re searching #tag1, that’s not a tag search — it just searches the text of note bodies instead of the index of tags.

Also, YAML tags do appear in the tag list. If they don’t, perhaps something is wrong with your YAML formatting. Try removing the indent before the -.

1 Like