When a new note is created, its name is by default “new note”. In some cases, it can be desirable to have a different or even a dynamic default note title.
For this use case, Trilium (since v0.52) supports #titleTemplate
label. You can create such a label for a given note, assign it a value, and this value will be used as a default title when creating child notes. As with other labels, you can make it inheritable to apply recursively, and you can even place it on the root note to have it applied globally everywhere.
As an example use case, imagine you collect books you’ve read in a given year like this:
Now, to the parent note “2022 Books” you can assign label #titleTemplate="[Author name]: [Book title], [Publication year]"
.
And all children of “2022 Books” will be created with initial title “[Author name]: [Book title], [Publication year]”. There’s no artificial intelligence here, the idea is to just prompt you to manually fill in the pieces of information into the note title by yourself.
The value of #titleTemplate
is evaluated at the point of note’s creation as a JavaScript string, which means it can be enriched with the help of JS string interpolation with dynamic data.
As an example, imagine you collect server outage incidents and write some notes. It looks like this:
You can automatize the date assignment by assigning a label #titleTemplate="${now.format('YYYY-MM-DD')}: "
to the parent note “Incidents”. Whenever a new child note is created, the title template is evaluated with the injected now object.
Second variable injected is parentNote, an example could be #titleTemplate="${parentNote.getLabelValue('authorName')}'s literary works"
.
See also [[template]] which provides similar capabilities, including default note’s content.