# Templates

A template is an ordinary note in your templates folder. Insert it into any note, and it fills in things like today's date for you.

## Set up a templates folder

Choose a folder in **Settings › Templates › Templates folder**. Every note inside it becomes a template you can insert.

If you haven't chosen one yet, the template picker offers **Create a Templates folder** or **Choose a folder…**. If your vault came from Obsidian with a templates folder set, Niv uses that one.

## Insert a template

Open the note you want to fill, then:

- press ⌘⇧T, or
- type `/` and choose **Template**, or
- press ⌘O, type `>` and choose **Insert template**.

Type to filter the list. ↑ and ↓ move, ↵ inserts, esc closes.

![The Insert template picker listing the notes in the templates folder](https://niv.md/docs-media/template-picker.dark.png)

## What a template can fill in

Templates use the same placeholders as Obsidian:

```
{{title}}           the note's title
{{date}}            today's date
{{time}}            the time now
{{date:YYYY-MM-DD}} a date in a format you choose
{{date+1d}}         tomorrow, and other offsets
{{cursor}}          where the cursor goes after inserting
```

Niv also reads Templater expressions, like `tp.date.now` and `tp.file.title`, written between Templater's tags.

In a recurring note, every date in the template is the date the note stands for, not the moment it was created. See [Daily and recurring notes](/p/docs/daily-and-recurring-notes).

A template's properties are added to the note too, once the note syncs with a Space. A note that's only on this device takes the template's text, and Niv tells you its properties were left out.

## Formats

In **Settings › Templates**:

- **Date format** and **Time format** use Moment tokens, like YYYY-MM-DD and HH:mm. The row shows today's date in the format you typed.
- **First day of the week** is Monday or Sunday, for week numbers in dates.

When the folder syncs with a Space, these settings belong to the Space and apply to everyone in it. Only owners and editors can change them. If this folder's settings differ from the Space's, Settings shows both and lets you choose **Use the Space's** or **Use this vault's**.

## Templates with code

Some templates carry code, written between Templater's code tags. Before it runs, Niv asks: **This template has code. Run it?**

The code can write in the note, rename or move it, and create notes. It can't reach the internet or anything outside your vault, and it runs only on this device. If the template changes, Niv asks again. Nothing happens until you choose **Run**.

## What Niv doesn't run

Some templates use things Niv doesn't run, like content fetched from the web, the clipboard, changes to other files or Obsidian internals. Niv tells you which, and inserts nothing. Your note stays as it was.

## Questions in templates

A template can ask you a few questions before it's inserted. Each question shows which template is asking. **Skip this** leaves one unanswered; **Cancel** writes nothing.

---

Published with [Niv](https://niv.md/) in the Space Docs.
