Templates

Summary

Templates are notes with pre-outlined content meant for reuse. Templates can either be inserted into an open note with Dendron: Insert Note, or automatically applied at note creation with Schemas. These are meant to reduce friction in the creation of new content, providing standardized outlines to your notes.

Details

The supported ways of using templates:

  1. The easiest way is to have a templates.* hierarchy in your vault and store commonly used note templates there. You can then re-use these templates in other notes by using the Dendron: Insert Note command in VS Code. By default, this hasn't been assigned a keybinding, but you can always map this to something easy to remember if you find yourself using a lot of templates.
  1. A more automatic way is by referencing templates in your schema and then having the template automatically applied when a new note of a particular type is created. This is described in more detail in the note on schemas.

Built-In Templates 🚧

You can also pick from a set of built-in templates that contain a set of commonly used note styles to help you get started. These templates can be pulled down with the seeds mechanism. The seed containing templates is called dendron.templates, substitute dendron.dendron-site for dendron.templates in the example below

Adding a seed to an existing workspace

In this example, dendron.dendron-site is the name of the seed. Replace this string with your desired seed.

  1. Open the command palette and run Add Seed to Workspace. In the dropdown, select dendron.dendron-site
  2. Wait for the seed to be imported. After the import, run Reload Index for Dendron to index the seed.

CLI

Adding a seed to an existing workspace

In this example, dendron.dendron-site is the name of the seed. Replace this string with your desired seed.

  1. Navigate to your current workspace
cd {workspace}
  1. Add the seed
dendron seed add dendron.dendron-site
  1. Open the workspace. You should find your workspace initialized with the contents from wiki.dendron.so.

  2. (Clean up)

dendron seed remove dendron.dendron-site

We are continually working to expand the types of templates available in the dendron.template seed.

Template Variables

Work In Progress 🚧

This section is actively being worked on and may be incomplete.

Date variables currently does not work in version 0.79 and later releases.

Dendron supports various template variables.

  • For inserting the current date and time:
    • CURRENT_YEAR: The current year
    • CURRENT_MONTH: The month as two digits (example '02')
    • CURRENT_DAY: The day of the month as two digits (example '08')
    • CURRENT_HOUR: The current hour in 24-hour clock format
    • CURRENT_MINUTE: The current minute as two digits
    • CURRENT_SECOND: The current second as two digits

Example:

  • template
    Today is {{ CURRENT_YEAR }}.{{ CURRENT_MONTH }}.{{ CURRENT_DAY }},
    
  • output
    Today is 2022.01.04
    

Backlinks