Frontmatter

Christofer Bäcklin, 2026-05-21

App websiteGitHub

Obsidian is used more and more by myself, colleagues, and teams around me. Currently I'm up to 5000 notes without including any LLM conversations, Jira tickets, or other context material. Having my brain on disk is all great and useful but I've increasingly started using it programatically, for querying, building automations, managing website content and apps on my platform. Well curated frontmatter is then key for reliability but is a pain to manage manually, especially if you need non-trivial refactoring.

It hit me that because you can query documents based on frontmatter with dataview, it should be straightforward to implement SQL-style data manipulation as well. SQL already did the thought work, it can go complex without getting unwieldy, and everybody knows it. It brings structure and safety to big operations that plain search-and-replace don't without forcing a DSL on people.

Said and done, I'm happy to present the fm CLI tool:

-- Step 1: Inspect current state
select vegan, vegetarian, veggie from "recipes/*.md";

-- Step 2: Normalize fields (errors if casting fails)
update "recipes/*.md" set vegan:bool, vegetarian:bool, veggie:bool, diet:list;

-- Step 3: Populate `diet` from existing fields
update "recipes/*.md" set diet+="vegan"      where vegan;
update "recipes/*.md" set diet+="vegetarian" where vegetarian or veggie;

-- Step 4: Verify results
select vegan, vegetarian, veggie, diet from "recipes/*.md" limit 100;

-- Step 5: Clean up deprecated fields
alter "recipes/*.md" drop vegan, vegetarian, veggie;

Above snippet goes through my recipes and turns the flags vegan, vegetarian and veggie (synonymous with vegetarian) into a list property diet into which I can later add other types.

Read more