Skip to content

Templates

Templates give you control over the initial content of new Objects. TypeMD supports two kinds of templates: object templates that provide default frontmatter and body content, and name templates that auto-generate Object names from patterns.

Each Type can have one or more object templates stored at templates/<type>/<name>.md. Templates are regular Markdown files with optional frontmatter and body content that serve as defaults when creating new Objects.

vault/
├── templates/
│ └── book/
│ ├── review.md # a "review" template for books
│ └── summary.md # a "summary" template for books
└── objects/
└── book/
└── ...

A template file can include frontmatter properties and body content:

---
status: to-read
tags:
- tag/to-review
---
## Summary
## Key Takeaways
## Notes

Template frontmatter properties override the schema’s default values. The template body becomes the initial body of the new Object.

When creating an Object with tmd object create, templates are resolved automatically:

  • No templates — proceeds without a template
  • Single template — auto-applied without prompting
  • Multiple templates — interactive prompt for selection (or use -t to skip the prompt)
Terminal window
# If book has one template, it auto-applies
tmd object create book clean-code
# Specify a template explicitly
tmd object create book clean-code -t review
# If multiple templates exist, you'll be prompted to choose
tmd object create book clean-code

Templates can override user-authored system properties (name, description, tags). Auto-managed system properties (created_at, updated_at) in templates are ignored — they always reflect the actual creation time. Properties in the template that are not defined in the type schema are silently ignored.

Object names are normally provided manually at creation time. For types with predictable naming patterns (daily journals, meeting notes, weekly reviews), this is repetitive and error-prone. Name templates let type schemas define auto-generated names using placeholders, enabling one-command object creation.

Add a name entry in the type schema’s properties array with a template field:

types/journal/schema.yaml
name: journal
emoji: 📓
properties:
- name: name
template: "日記 {{ date:YYYY-MM-DD }}"
- name: mood
type: select
options:
- value: good
- value: okay
- value: bad

The name entry in properties only allows the template field — no type, options, pin, emoji, or other property fields.

The {{ date:FORMAT }} placeholder accepts the following format tokens:

TokenDescriptionExample
YYYYFour-digit year2026
MMTwo-digit month03
DDTwo-digit day14
HHTwo-digit hour (24h)09
mmTwo-digit minute30
ssTwo-digit second05

Examples:

TemplateResult (on 2026-03-14 09:30)
日記 {{ date:YYYY-MM-DD }}日記 2026-03-14
Meeting {{ date:YYYY-MM-DD HH:mm }}Meeting 2026-03-14 09:30
Week {{ date:YYYY-MM }}Week 2026-03
Weekly ReviewWeekly Review (no placeholders, used as literal)

When a type has a name template, the name argument is optional:

Terminal window
# Name auto-generated from template
tmd object create journal
# Explicit name overrides the template
tmd object create journal "my-journal"

If a type does not have a name template, the name argument is required.