Autocomplete Tags in YAML front matter

Use case or problem

tags in YAML front matter is time consuming because the autocomplete feature doesn’t work for tag names, unless the tag is input with a hash symbol in front of it.

Proposed solution

implement Autocomplete in the YAML front matter

Current workaround (optional)

No work around as such.

YAML only recognizes strings, and that means I have to type the tag with the hah symbol so as to make use of the autocomplete, and then engulf the tag in single braces. This takes quite some time!

Related feature requests (optional)

51 Likes

I’d love this feature as well, but I do have a workaround.

  1. start typing #<tag goes here..> in the YAML frontmatter. You’ll find autocomplete options.
  2. Select what you want
  3. Remember to delete the # at the beginning, otherwise it’ll be considered a comment.
15 Likes

I am also facing this issue and it would be great that tags autocomplete in YAML frontmatter. Ideally, both "#…" and plain text should work for autocomplete, in both list and bracket formats (having already one of all working would be nice).

3 Likes

Thank you! I was searching the forum looking for exactly this. I just started actively using YAML frontmatter in the last couple of days. Every new note has it with tags, and if I pull up an older note that doesn’t, I add. Really working for me… except for the autocomplete issue. I was finding I was also needing to use the Tag Wrangler plug-in regularly to rename/combine tags.

I’ll try the workaround of typing # and then removing, but not ideal.

3 Likes

I solved it with the AHK script (Autohotkey app for PC must installed). I will write in the line: tags: [ #newtag ] when I will suggest the used tags. I stay in line and run the script. He first checks to see if I’m in the tags: line and then removes all # characters in that line in bulk.

Probably a better script to write, but I’m a beginner.

#IfWinActive, ahk_exe Obsidian.exe ;you must by in the obsidian window
{
 ; CTR+SHIFT+A shortcut for run the script. Character "A" you can change it for your own shortcut
^+a::Gosub, obsidianHashTagReplace
return
}

obsidianHashTagReplace:
send, {home}
send, +{End}
send, ^c
If InStr(Clipboard, "tags: [")
{
} Else {
	MsgBox, You are probably not in the YAML Tag line.
	Exit
}
Clipboard := StrReplace(Clipboard,"#","")
send, ^v
return
1 Like

I am assuming that this patch isn’t yet a plugin, or accessible to the majority of Obsidian users,

so the feature request is still alive?

Agreed. I have to remove the extra # symbol every time

Want this feature!

If this is still an issue for others, it’s possible to retain the # by quoting each tag after autocompleting or quoting them all together. This works for me in v0.12.15 without issue:

This one seems to be the most practical for me:

tags: "#tag1 #tag2 #tag3"

These also work though:

tags: "#tag1" "#tag2" "#tag3"

…or…

tags:
  - "#tag1"
  - "#tag2"
  - "#tag3"
1 Like

The Obsidian linter plugin now has has a rule to reformat tags in the YAML frontmatter, which also solves the issue conveniently.

11 Likes

Use case or problem

This is about tags in the metadata section.

---
# metadata section
tags: some_tag, #some_other_tag
---

# normal document

If I write some_tag I do not get any suggestions from existing tags. I might mistype it and not who up in a query for the real spelling.

If I type it with # like #some_other_tag I do get suggestions. But after saving/closing the document. It does not show up in searches for the tag. It does not count as tagged with some_other_tag.
I suspect it is treated as a comment but I don’t think it should.

Proposed solution

Two approaches:

  1. Don’t ignore tags with#. The search (and links, etc.) for tags:#some_other_tag should should the document with the line tags: #some_other_tag
  2. When typing something in the metadata section on the line beginning with tags: , suggest tags like when typing #

Current workaround (optional)

Use # for suggestions and the delete the #. :frowning_face:

1 Like

Another workaround in the meantime: Frontmatter Tag Suggest Plugin, not in the store yet but available to install manually or through BRAT

8 Likes

Hi,
I just checked on Mobile. Frontmatter Tags work as expected in Search. I enter my Frontmatter Tags like so in Edit Mode:

tags: [Fotografie Fujifilm Filmsimulation Astia]

and they show in the Metadata section in Preview Mode like so:

Tags #Fotografie #Fujifilm #Filmsimulation #Astia

This is what I do and it works great, but I definitely second this feature request. If tags in frontmatter are officially supported, autocomplete for tags in frontmatter should be too.

3 Likes

Agreed. I see the reliance on plugins as a good thing, but I think autocomplete should be the default, if YAML is native.

2 Likes

Now in the store, and works great.

2 Likes

Well that solves half of my problem. I also agree that this should just be a default behavior built into Obsidian.

My other issue is that tags in the frontmatter won’t get the text formatting and become clickable like they do elsewhere. Unfortunately I’ll still be writing tags on a separate line right under the frontmatter in dataview inline format instead:

---
aliases: []
---
tags:: #tag1 #tagsss/tag2
# Note Title
2 Likes

True, but that should be a different feature request.

That is just another list format in YAML, and it still doesn’t support autocomplete. it’s effectively the same as

tags:
- tags 1
- tags 2

will be implemented in v1.4

1 Like