Skip to content
Docs

Jinja Templates

Data content is specified in the markmeld config through options like md_files, yaml_globs, and more. Markmeld loads this data and runs it through a Jinja template.

Use content as the standard name for your main document:

data:
md_files:
content: manuscript.md

In your template:

{{ content }}

For multiple documents, use descriptive names:

data:
md_files:
content: manuscript.md
supplement: appendix.md

Specify a key for each file:

data:
md_files:
my_md_file: path/to/file1.md
yaml_files:
my_yaml_file: path/to/file2.yaml

Access markdown content directly:

{{ my_md_file }}

Access YAML as a dictionary:

{{ my_yaml_file.variable_name }}

For md_globs and yaml_globs, content is available under the filename (without extension):

data:
md_globs:
- chapters/*.md
{{ chapter1 }}

Define variables directly in config:

data:
variables:
author: "Jane Doe"
year: 2025

Access them: {{ author }}, {{ year }}

Markmeld provides these automatically:

  • {{ _today }} — Today’s date (YYYY-MM-DD)
  • {{ _now }} — Current UNIX timestamp
  • {{ target_name }} — Current target name
  • {{ _global_frontmatter }} — Merged frontmatter from all sources
  • {{ _local_frontmatter }} — Frontmatter by file key
  • {{ _md }} — Structured access to markdown content
  • {{ _yaml }} — Structured access to YAML content
targets:
my_target:
frontmatter:
csl: "nature.csl"
data:
md_files:
content: manuscript.md
targets:
my_target:
frontmatter_overrides:
lab: "Sheffield Lab"
frontmatter < md frontmatter < yaml data < variables < frontmatter_overrides

For loops and dynamic templates:

data:
md_files:
intro: md/01-intro.md
chapter1: md/02-chapter.md
variables:
chapters: [intro, chapter1]
{% for chapter in chapters %}
{{ _md[chapter].content }}
{% endfor %}

Properties: .content, .frontmatter, .path, .ext

{{ some_date | date(to_format="%B %d, %Y") }}
{% set refs = content | extract_refs %}