stuff i did to make my obsidian writing vault cooler

i have an obsidian vault for my personal writing. it has been a mess for a while. today i tried to mitigate that a bit by creating a frontmatter template and installing a plugin that lets me sort my folders just the way i wanted. somehow i actually got some writing done BEFORE i spent time on this! take that, impulse to focus energy on organization rather than doing anything productive!
templater
templater is a super powerful plugin that is almost entirely beyond me. javascript is fucking terrifying ok. so most, if not all, of the following template is stolen from obsidian forums and various blogs. sorry random people! i hope you are ok with me sharing my hacked up version of your code!
what the below template will do, either when using it to create a new note or applying it to an existing note, is the following:
- the title is pulled straight from the note's file name; if the note doesn't exist, it prompts you for a title
- it will then show a list of all of your tags, and you can click multiple instead of just one. you have to click the
ESC
button to get to the next dialog though. - next, you're prompted for the "status" — in the template, this is just a small array of options: complete, work in progress, outline, saved. some of these would do better under a property of their own called "type" or something but i wanted to save space.
after you input those options... you have a note with all the stuff you inputted!!! how cool is that!
templater can be frustrating, especially if you don't know javascript (the map
thing to get the hashtags out of the tags was annoying! and i had to do that because the YAML frontmatter recognizes hashtags as comments), but when it works, it works. super satisfying stuff.
here's the code:
<%*
tR += "---" + "\n"
let title = tp.file.title
if (title.startsWith("Untitled")) {
title = await tp.system.prompt("Title");
await tp.file.rename(title);
}
tR += "title: " + title + "\n"
let date = tp.file.creation_date("YYYY-MM-DD")
tR += "date: " + date + "\n"
const allTags = Object.entries(app.metadataCache.getTags())
.sort( (a, b) => a[0].localeCompare(b[0]) )
let selectMore = true
let selectedTags = []
while (selectMore) {
let choice = await tp.system.suggester((t) => t[0] + "(" + t[1] + ")", allTags, false, "[Select more tags (ESC when finished)] - " + selectedTags.map(x => x.replace("#", "")))
if (!choice) {
selectMore = false
} else {
selectedTags.push(choice[0])
}
}
tR += "tags: " + selectedTags.map(x => x.replace("#", "")) + "\n"
let status = await tp.system.suggester((item) => item, ["complete", "work in progress", "outline", "saved"])
tR += "status: " + status + "\n"
tR += "---"
%>
obsidian custom sort
before, my writing was organized by note name. each name would start with a date and then the piece's title. i did this so they would display in a sort order according to when i wrote them. when i did the above template edits, i decided to take out those dates. but then my notes were in alphabetical order and i didn't want that!
enter obsidian custom sort. this one is a bit confusing, but not nearly as much as templater. all you have to do is plop a special file called sortspec
into a folder, customize the options according to the docs (which are really well done!), and then you have your custom sort order! it's really cool.
the following sortspec
file will apply to files in the same directory as it:
---
sorting-spec: |-
target-folder: .
> a-z by-metadata: date
---
if you change the target-folder
line to target-folder: ./*
, it'll apply to the same directory, and all sub-directories! i did this for a few other folders where i had a ton of sub-folders.
the custom sorting stuff is super powerful so i highly recommend giving it a try if you're as particular as me about how each folder should be sorted lol
happy writing, friends!