Obsidian Templater Automates Note-Taking System

In the last article, we talked about the Obsidian core plugin Templates which already do a good job in the sense that it allows us to pre-define a note structure or format that could be applied to our notes. Templater is an Obsidian community plugin that also empowers us to define a note structure to be used by our notes. So, the question is what is the difference between these two? Which one should we choose? Well, it’s critical to understand the main difference between these two though, and the additional benefits we could get from Templater, otherwise, we are not using our time and efforts wisely when it comes to learning new skills.

Differences Between Obsidian Templater vs Templates

Difference #1: Initial Setup

Templates is a core plugin we could just enable and start using. As for Templater, we need to download it and enable it before using it.

This setup difference doesn’t help us make up decisions about which one to use at all. But the next difference would blow your mind which is
AUTOMATION.

Difference #2: Obsidian Templater Automation

When we are working with the core plugin — Templates, we think that’s probably what a template is capable of. We first create a template by defining some metadata and note structure, with some basic variables like {{date}}, {{title}} and apply it to a new note by following two steps — “Insert template” and select the template you want to apply to the note. In the note-taking process, a template saves us tons of time, especially when we create notes frequently.

But, the core plugin Templates only provides the very basic capabilities of what a regular template can do. When we create templates using Templates, I don’t think of it as something more than a plain text template. The variables you could use in your template and the dynamic data generated based on the variables are very limited. It’s a copy of some structure and pasted into a note. Somehow, it limits our imagination of the creative note-taking process.

However, after some experiments with Templater, I consider it a powerful template as it allows us to create any powerful template based on the variables and scripts that we use in the template. But with Templater, you are programmatically changing anything on the fly. With the automation power provided by Templater, our note-taking experience goes up to another level. It empowers you to create notes in a way you probably won’t think is possible.

Understand the Obsidian Templater Automation System

The concept of automation provided by Templater is reflected in two aspects:

  • We are empowered to create powerful templates to be applied to our notes.
  • Automatically applying the template — Using Hotkey — apply a specific template automatically — Using Folder templates — apply the template that is assigned to a folder to any new note creation to that folder

Obsidian Templater Commands/Functions

Let’s get to learn some basic Templater functions before building them into our templates.

Steps to writing Templater command as beginners:

  • Open a blank note
  • Start typing the command below
  • Leverage the auto-completion when you type out the functions
  • Return the function value via command — Templater: Replace the templates in active file
Writing Templater functions and returning the value. GIF by Amy Li.

Make Sense of <% .. %>

Whenever you are using Templater to create your template, you always start with the opening tag <%`, ends with a closing tag `%> is what we will call a command.

Since Templater commands(functions) are only recognized and run by Templater. As users of Templater, we need to tell Templater which is the command inside our note. So, we use this <% and %> to surround our command script, setting it bondable to other text in the note.

tp.date

Today: <% tp.date.now("YYYY-MM-DD") %>
Yesterday: <% tp.date.yesterday("YYYY-MM-DD") %>
Tomorrow: <% tp.date.tomorrow("YYYY-MM-DD") %>
Next week: <% tp.date.now("dddd Do MMMM YYYY", 7) %>
Next month<% tp.date.now("YYYY-MM-DD", "P1M") %>
Last month<% tp.date.now("YYYY-MM-DD", "P-1M") %>

tp.file

For example, we could generate various dates, that could be today, yesterday, tomorrow, next week, or next month for the new note, the file-related variables like file name, folder, the creation time modified time, and even moving our note to a folder automatically, prompting the user to input some data. etc. We could create a note with the various dynamic data on the fly based on the variables.

 File name: <% tp.file.title %>
File folder: <% tp.file.folder() %>
Creation date: <% tp.file.creation_date() %>
Modified date: <% tp.file.last_modified_date() %>
Demo the basic Obsidian Templater commands. Screen shoot by Amy Li.

Advice for Beginners

But before going over other functions, I would like to provide some learning tips for beginners, especially for those who don’t have a programming background. If you have a programming background, it’s easy to get used to the command script. But for non-programmers, I do have some tips to get started properly. When we look at the documentation, there are tons of various commands. Let’s try not to get trapped in the learning cycle such as spending several hours trying to memorize as many commands as we could. Just pick the ones you need for your current work, not your future work, but only your current work because as you put it into practice, and start to use it, you are not distracted by the other beautiful and fancy commands. If you don’t need it, any fancy command is not worth your attention. And once you start using Templater at your daily work with just one command, the confidence and skills will be picked up as time passes on to some point that you are fully capable of playing around with many other commands. Right now, especially for beginners, it’s important to know what we want and then personalized our templates with Templater.

Another thing to be clear is that even if you don’t grip the idea of commands, scripts, functions, invoke a function, etc., it doesn’t affect your capability of using it. Right. It’s like I don’t know how a GPU works or how the computer is built, but I still can be a programmer. Similarly, we can be smartphone users without understanding how the iOS system is running in the background.

Templater Automation 1: Creating Powerful Templates to Generate Efficient Notes

To build up our skills in using Templater commands, let’s build the commands into different variations of a template.

Creating templates with Templater commands. Screenshots by Amy Li.

Templater Automation 2: Apply Templates Automatically

Templater provides two ways of automatically applying templates to new notes.

  • Folder Templates
  • Template Hotkey

Apply Templates #1: Folder Templates

Steps to follow to use Folder Templates provided by Templater:

  1. Create a template and move it to your templates folder
  2. Open the Templater settings page
  3. Under the Folder Templates, and provides a folder path, as well as assigning a template to that folder
  4. Create a new note for the given folder
  5. The template will be automatically applied to the new note.
Left: Demo applying a template using the Folder Templates approach. Right: The structure of a template. Images by Amy Li.

Apply Templates #2: Template Hotkey

Templater provides two ways of using templates: Let’s learn the first approach: Steps to follow to use Template Hotkeys provided by Templater:

  1. Create a template and move it to your templates folder
  2. Open the Templater settings page
  3. Under the Template Hotkeys, assign a hotkey for this template
  4. Create a new note (windows: CTRL+N, mac: CMD +N).
  5. Apply the template using the assigned hotkey in step 3
Left: Demo applying a template using the Templates Hotkey approach. Right: The structure of a template. Images by Amy Li.

Advice for the Pick

Well, if you are certain that you will only apply one specific template to all the notes within a given folder, then you could adopt the Folder Templates approach. Otherwise, it makes more sense to use the Template Hotkeys approach.

Wrap Up

I want to wrap up this video by repeating these words for beginners: it’s much more important to know how to use the Templater commands than memorizing various commands you will never use at your work.

Visit more tutorials on our website.

Index