How to bulk add tags to markdown frontmatter with YQ
· 4 min read
I keep my notes in markdown format, with tags stored in frontmatter. Sometimes I need to apply a particular tag to all notes in a folder. This post describes how to do that using yq.
YQ, the yaml query tool
View All TagsI keep my notes in markdown format, with tags stored in frontmatter. Sometimes I need to apply a particular tag to all notes in a folder. This post describes how to do that using yq.
YQ supports operating and transforming YAML front matter via the --front-matter flag.
For example, when using a file that has front matter, yq can extract the YAML correctly:
$ yq --front-matter=extract '.' ./with-frontmatter.md.txt
---
key: value
However, it behaves unexpectedly when the file does not have any front matter.