Obsidian Tip of the Day: Three Templater Snippets for All Your Note Templates in #Obsidian
If you use the Templater community plugin (and you really should) you have three snippets available to you which provide a real asset in creating metadata in your note templates. These dynamic entries allow you to automatically add the creation date, modification date and note name to your new notes. Never again will you have to bear the indignity of a note that decides to call itself Untitled. To add these to your templates, edit them with source mode turned on instead of live preview which is the Obsidian default.
Note Name
This snippet gives you a pop-up when you first create your notes asking you to name it then. You type the name into the resulting dialog box and that’s that taken care of. (Note: This snippet goes at the very top of your note at Line 1. It creates the three tick marks that are the beginning of the code block for your properties.)
<%*
let title = tp.file.title
if (title.startsWith("Untitled")) {
title = await tp.system.prompt("Title");
await tp.file.rename(title);
}
tR += "---"
%>
Creation Date
This snippet will provide you with the creation date of your new note instead of the creation date of the template itself which is sometimes a problem when using dates in templates. If you use a different date format, replace the format here within the quotation marks.
<% tp.date.now("YYYY-MM-DD") %>
Modification Date
This snippet will provide you with a properties field that will update itself whenever you edit a note. As above, if you use a different date format, replace the format here within the quotation marks.
<% tp.file.last_modified_date("YYYY-MM-DD") %>