Generate your frontmatter on save.
✅ Powerful, dead simple
- after install the plugin, visit the setting of the plugin
- change the frontmatter template
for example, the following frontmatter template
{
folder: file.parent.path,
title: file.basename,
test: ["1", "2"]
}
will generate this in the file Good recipes/scrambled egg.md
on save.
folder: Good recipes
title: scrambled egg
test:
- '1'
- '2'
- install obsidian-custom-save and add the
frontmatter-generator: run file
command to the custom save actions
- Basic Demo: https://youtu.be/Cz9d5e1WQVM
- Tag properties demo: https://www.youtube.com/watch?v=lyhrOG2Sn88&t=16
file.properties?.type === 'kanban'
? {
folder: file.parent.path,
title: file.basename
}
: {}
{
test: (() => {
return { test: 'test' }
})()
}
{
numberOfPages: dv.pages('#ai').length
}
It could be a json or a javascript expression that return an object.
^ even functions work
file
, theTFile
objectfile.properties
will access the yaml object of the current filefile.tags
, astring[]
which will access the tags of the current file. For example["#book", "#movie"]
dv
, the dataview object (you can only access this if you install and enable the dataview plugin)z
, the zod object
You can find it on obsidian plugin marketplace.
- cd to
.obsidian/plugins
- git clone this repo
cd obsidian-frontmatter-generator && bun install && bun run build
- there you go 🎉
- to stop generate on a file, you can put
yaml-gen-ignore: true
on the frontmatter. You can also ignore the whole folder in the seting. - the context that you can access is TFile. This can be update in the future. It is extremely flexible.
- This plugin also comes with some command to run in folder and in the whole vault.
- If you want to contribute, first open an issue.
- 🚨 This plugin is still under development, don't try to hack it by using weird keywords or accessing global variables in the template. It should not work but if you figure out a way to hack it, it will just break your own vault.