Tags In Front Matter, dataview and search #confused

Some background… I use obsidian on the iPad…

Ok so… I see behavior in tags in front matter that confuses me. If I put the hashtag in like so.

tags: #tag1, #tag2

the tags don’t seem to work in dataview queries as from. i.e.
table date
from #tag1

If I take the # off like
tags: tag1, tag2

it does work in said query.

If I do a search they do seem to work with the #tag but not in the dataview.

What am I not understanding about frontmatter and the # portion of tags?

Having a # symbol in YAML is not valid.
To search for tags you should use this syntax in the core search plugin: tag:#tag1.
If you just use #tag in your search query you are searching for that exact string to show up.


When defining tags in the metadata, don’t use the # symbol:


1 Like

Actually I get a “Invalid YAML” error when entering tags like that.
I find that this does work

- Tag1
- Tag2

Try putting the tag in double quotes with the hashtag. Like this: “#tag2

1 Like

The Obsidian Help page for YAML shows valid lists as

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

The help page for tags shows an indented list:

  - 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?


This is a great summary. I’ll add it to the beginner’s guide giving you attribution. Thanks.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.