Templates Plugin
This plugin allows you to create templates in Joplin and use them to create new notes and to-dos.
๐ New to the plugin? Checkout the Templates AI Assistant for creating templates using AI without having to learn the template syntax yourself.
Table of contents
Installing Plugin
- Open Joplin
- Go to Tools > Options > Plugins
- Search for
Templates
- Click Install plugin
- Restart Joplin to enable the plugin
Importing Legacy Templates
If you were already using the legacy version of templates, your templates will be automatically imported once you install the plugin. They will appear in an Imported Templates - dd/mm/yyyy notebook. See the README note in that notebook for more details.
Your existing templates will still be present in the templates directory but will be renamed from .md to .md.old. You can safely delete these old templates once you verify that they've been imported correctly in Joplin.
Using the Template Plugin
Adding a new template
Create templates by creating a new note or to-do in any notebook that:
- Includes your template content
- Is tagged with
template
Using templates
You can access the templates options in Tools > Templates.
Features
After going through this section, check out the Complete Feature Demonstration Template to see all features in action with examples and expected outputs.
Template variables
Built in variables
Built in variables are inserted automatically, without interaction from you. For example, in the following template, the date will be automatically added:
Date: {{date}}
Hours:
Details:
The currently supported built in template variables are:
| Variable |
Description |
Example |
{{date}} |
Today's date |
2019-01-01 |
{{time}} |
Current time |
13:00 |
{{datetime}} |
Current date and time |
01/01/19 1:00 PM |
{{#custom_datetime}} |
Current date and/or time formatted based on a supplied string (using moment.js formatting) |
{{#custom_datetime}}M d{{/custom_datetime}} |
{{bowm}} |
Date of the beginning of the week (when week starts on Monday) |
|
{{bows}} |
Date of the beginning of the week (when week starts on Sunday) |
|
{{note_id}} |
ID of the note/to-do created using this template. |
|
NOTE: All dates are formatted based on your Joplin settings in General > Date Format
Custom variables
You can also define custom variables in your template that prompt you to enter a value when you use the template. For example in the following example the name and color variables will prompt you each time you use the template:
---
name: text
color: dropdown(Red, Yellow, Green)
---
Hi there, {{ name }}. Your favorite color is {{ color }}. This note/to-do was created on {{ datetime }}.
The currently supported custom variable types are:
| Type |
Example |
text |
name: text |
number |
count: number |
boolean |
show_summary: boolean |
date |
meeting_date: date |
time |
meeting_time: time |
dropdown |
color: dropdown(Red, Yellow) |
Points to note
- You can't use special characters ("@", ",", "#", "+", "(", etc.) or spaces in variable names. However, you can use "_" in variable names.
- If you declare a custom variable with same name as the built-in variables, the custom variable value will be used.
- Internally, Handlebars.Js is used to compile the templates. You can write templates to be compatible with
Handlebars.
Advanced Usage
You can also define a label for each custom variable. Label is something that appears instead of the variable name in the variables input dialog. You can use the following syntax to do so.
---
name: text
project:
label: Select a project
type: dropdown(project 1, project 2, project 3)
show_summary:
label: Add summary in note?
type: boolean
---
Hi {{ name }},
This is a report for {{ project }}.
{{#if show_summary}}
## Summary
> Enter the summary here.
{{/if}}
Points to note
- The indentation should be
2 spaces exactly. Don't use tabs for indentation otherwise it can result in errors.
Special variables
These are the variables that have a specific purpose other than being used in templates. Some of the important features of these special variables are
- Both built-in and custom variables can be used while defining these variables.
- The values of these variables can be used in the template body just like built-in and custom variables.
Currently there are four special variables.
| Variable |
Purpose |
Example |
template_title |
Title of the note/to-do created using this template. |
template_title: Standup - {{ date }} |
template_tags |
Comma separated tags to be applied to the note/to-do created using this template. |
template_tags: spec, {{ project }} |
template_notebook |
The ID of the target notebook for this template. Whenever a new note/to-do will be created by this template, it will be created in this target notebook. |
template_notebook: 82d2384b025f44588e4d3851a1237028 |
template_todo_alarm |
The date and time for a to-do alarm/reminder. Only applies when creating to-dos from templates. |
template_todo_alarm: {{ datetime delta_days=1 format="YYYY-MM-DD HH:mm" }} |
Points to note
- If
template_title is not provided, the title of the template will be used as a fallback value.
- If a tag specified in
template_tags doesn't exist already, it will be created.
- You can't use these variable names i.e.
template_title, template_tags, template_notebook, and template_todo_alarm for custom variables. In general, please avoid defining custom variables with template_ prefix.
- To get the ID of a notebook, you can right click on that notebook and click on
Copy notebook ID.
- While you are inserting the template in an existing note/to-do,
template_tags variable is used to apply those tags to the note the template is inserted in. However, you can disable using template_tags while inserting templates from the plugin settings.
- The
template_todo_alarm variable expects a date-time string in the format "YYYY-MM-DD HH:mm" (without seconds). You can use the datetime helper to generate properly formatted timestamps.
Example of a template using special variables
---
project: dropdown(project 1, project 2)
template_title: Weekly Meet - {{ project }} - {{ date }}
template_tags: meeting notes, {{ project }}
---
## {{ template_title }}
This note contains the meeting minutes of the weekly meet held on {{ datetime }} for {{ project }}.
Advanced Template Features (Helpers)
The plugin uses Handlebars.js as its templating engine, which provides powerful helpers for advanced template logic. These helpers allow you to perform comparisons, mathematical operations, text transformations, loops, and complex date/time manipulations.
๐ก Tip: See the Complete Feature Demonstration Template for a comprehensive example using all helpers together in a real-world scenario.
Compare Helper
The compare helper allows you to compare two values using various operators. This is useful for conditional logic in your templates.
Syntax: {{#if (compare value1 operator value2)}}...{{/if}}
Supported operators:
| Operator |
Alternative Names |
Description |
== |
eq, equals |
Equal (type coercion) |
=== |
seq, strictly-equals |
Strictly equal (no type coercion) |
!= |
ne, not-equals |
Not equal |
!== |
sne, strictly-not-equals |
Strictly not equal |
< |
lt, less-than |
Less than |
<= |
lte, less-than-equals |
Less than or equal |
> |
gt, greater-than |
Greater than |
>= |
gte, greater-than-equals |
Greater than or equal |
Example:
---
age: number
temperature: number
---
{{#if (compare age ">" 18)}}
You are an adult.
{{else}}
You are a minor.
{{/if}}
{{#if (compare temperature ">=" 30)}}
It's hot outside! ๐
{{else if (compare temperature "<" 10)}}
It's cold outside! โ๏ธ
{{else}}
The weather is pleasant.
{{/if}}
Condition Helper
The condition helper provides logical operators for combining multiple conditions.
Syntax: {{#if (condition value1 operator value2)}}...{{/if}}
Supported operators:
| Operator |
Alternative Names |
Description |
&& |
and |
Logical AND |
|| |
or |
Logical OR |
Example:
---
show_summary: boolean
has_data: boolean
is_weekend: boolean
---
{{#if (condition show_summary "and" has_data)}}
## Summary
Data is available and summary display is enabled.
{{/if}}
{{#if (condition is_weekend "or" (compare temperature ">" 25))}}
Perfect day for outdoor activities!
{{/if}}
{{! For negation, use Handlebars' built-in unless helper }}
{{#unless show_summary}}
Summary is hidden.
{{/unless}}
Note: For simple boolean negation, use Handlebars' built-in {{#unless variable}} helper instead of the condition helper.
Math Helper
The math helper performs mathematical operations on numbers.
Syntax: {{math value1 operator value2}}
Supported operators:
| Operator |
Description |
+ |
Addition |
- |
Subtraction |
* |
Multiplication |
/ |
Division |
** |
Exponentiation (power) |
% |
Modulo (remainder) |
Example:
---
price: number
quantity: number
tax_rate: number
---
# Invoice
Price per item: ${{price}}
Quantity: {{quantity}}
Subtotal: ${{math price "*" quantity}}
Tax ({{math tax_rate "*" 100}}%): ${{math (math price "*" quantity) "*" tax_rate}}
**Total: ${{math (math price "*" quantity) "*" (math 1 "+" tax_rate)}}**
---
Area of circle with radius 5: {{math (math 5 "**" 2) "*" 3.14159}}
Case Helper
The case helper transforms text to different cases.
Syntax: {{case type text}}
Supported types:
| Type |
Description |
upper |
Convert to UPPERCASE |
lower |
Convert to lowercase |
Example:
---
name: text
company: text
---
# Welcome {{case "upper" name}}!
Company: {{case "upper" company}}
Email: {{case "lower" name}}@{{case "lower" company}}.com