Tags In Front Matter, dataview and search #confused

The Obsidian Help page for YAML shows valid lists as

key3: [one, two, three]
key4:
- four
- five
- six

The help page for tags shows an indented list:

tags:
  - tag1
  - tag2

The help page on aliases shows the all-on-one-line, surrounded by [ ], comma-separated list again (same as key3 above).

I use that same comma-separated list surrounded by [ ] for tags as well, to save vertical space on my screen.

tags: [tag1, tag2]

The version from Craig’s post, without the [ ], also works for me.

The version from DeniseTodd’s post works for me for a single tag, or when I have my full list inside [ ].

Combining the usage of Craig and DeniseTodd does NOT work for me. The local graph no longer recognizes any of the tags.

To summarize and show some additional combinations:

  • tags: [tag1, tag2] works and is one of the list syntaxes in the Obsidian help YAML page
  • The other list syntax puts each tag on a new line, following a -. See above. Based on the help vault, the lines can either be indented or not. No [ ] needed.
  • tags: [#tag1, #tag2] DOES NOT WORK # is illegal in YAML.
  • tags: ["#tag1", "#tag2"] seems to work (quotes escape the illegal # symbol), example from DeniseTodd.
  • tags: tag1, tag2 seems to work, example from Craig. I think this is only because the set of characters allowed in tag names is limited.
  • tags: "#tag1", "#tag2" DOES NOT WORK. Cannot combine the examples from Craig and DeniseTodd.
  • tags: "tag1", "tag2" DOES NOT WORK. Cannot use Craig’s example with quotation marks.
  • tags: ["tag1", "tag2"] seems to work. Can quote your tags even if not escaping anything, but need the proper list syntax with [ ].
  • tags: [tag1, "#tag2"] seems to work. Can mix quoted+escaped# and not quoted, if you use proper list syntax with [ ]. This seems like it might be confusing when you look at the note in the future, though!
  • tags: [ tag1, tag2 ] seems to work, not sensitive to extra space.

I’ll be sticking with tags: [tag1, tag2] since that list syntax is on the official Obsidian help page for YAML, but it is interesting to know about the other variants! I wonder if all the ones that work are supposed to work?

3 Likes