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.
Standard variable naming
Section titled “Standard variable naming”Use content as the standard name for your main document:
data: md_files: content: manuscript.mdIn your template:
{{ content }}For multiple documents, use descriptive names:
data: md_files: content: manuscript.md supplement: appendix.mdFile directives
Section titled “File directives”md_files and yaml_files
Section titled “md_files and yaml_files”Specify a key for each file:
data: md_files: my_md_file: path/to/file1.md yaml_files: my_yaml_file: path/to/file2.yamlAccess 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 }}Variables directive
Section titled “Variables directive”Define variables directly in config:
data: variables: author: "Jane Doe" year: 2025Access them: {{ author }}, {{ year }}
Special variables
Section titled “Special variables”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
Frontmatter
Section titled “Frontmatter”Base defaults
Section titled “Base defaults”targets: my_target: frontmatter: csl: "nature.csl" data: md_files: content: manuscript.mdOverrides (always win)
Section titled “Overrides (always win)”targets: my_target: frontmatter_overrides: lab: "Sheffield Lab"Precedence
Section titled “Precedence”frontmatter < md frontmatter < yaml data < variables < frontmatter_overridesDynamic access with _md
Section titled “Dynamic access with _md”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
Custom filters
Section titled “Custom filters”date filter
Section titled “date filter”{{ some_date | date(to_format="%B %d, %Y") }}extract_refs filter
Section titled “extract_refs filter”{% set refs = content | extract_refs %}