Template - obsidian-nvim/obsidian.nvim GitHub Wiki
To insert a template in the current note, run the command :Obsidian template
. This will open a list of available templates in your templates folder with your preferred picker. Select a template and hit <CR>
to insert.
To create a new note from a template, run the command :Obsidian new_from_template
. This will prompt you for an optional path for the new note and will open a list of available templates in your templates folder with your preferred picker. Select a template and hit <CR>
to create the new note with the selected template.
Substitutions for {{id}}
, {{title}}
, {{path}}
, {{date}}
, and {{time}}
are supported out-of-the-box.
For example, with the following configuration
{
-- other fields ...
templates = {
folder = "my-templates-folder",
date_format = "%Y-%m-%d-%a",
time_format = "%H:%M",
},
}
and the file ~/my-vault/my-templates-folder/note template.md
:
# {{title}}
Date created: {{date}}
creating the note Configuring Neovim.md
and executing :Obsidian template
will insert
# Configuring Neovim
Date created: 2023-03-01-Wed
above the cursor position.
You can also define custom template substitutions with the configuration field templates.substitutions
. For example, to automatically substitute the template variable {{yesterday}}
when inserting a template, you could add this to your config:
{
-- other fields ...
templates = {
substitutions = {
yesterday = function()
return os.date("%Y-%m-%d", os.time() - 86400)
end
}
}