# Pandoc Templates Pandoc templates control how output documents are formatted and styled during conversion. They separate content (Markdown) from presentation (layout, typography, structure). ## Template Syntax Pandoc uses `$...
or `${...}` delimiters. **Variables** — interpolated from document metadata or `-V key=value` CLI flags: ``` $title$ ${author}$ ``` **Conditionals:** ``` $if(abstract)$ $abstract$ $endif$ ``` **Loops** — iterate over arrays: ``` $for(author)$ $author$sep$, $endfor$ ``` **Partials** — include subtemplates: ``` ${ styles() }$ ``` **Pipes** — transform values (e.g., `$title/uppercase
). ## Using Templates ```bash # View the default template for a format pandoc -D html pandoc -D latex # Use a custom template pandoc input.md --template=mytemplate.html -o output.html # Override the default permanently # Place in <user-data-dir>/templates/default.<format> ``` The `--template` flag implies `--standalone` (generates a complete document, not a fragment). ## Key Template Variables | Variable | Description | |---|---| | `title`, `author`, `date` | Core metadata | | `lang` | Document language (BCP 47) | | `abstract`, `keywords` | Academic metadata | | `toc` | Table of contents | | `fontsize`, `fontfamily` | LaTeX/PDF typography | | `geometry` | LaTeX page geometry | | `css` | HTML stylesheet | Pass custom variables via `-V key=value` or set them in frontmatter. ## Community Templates (pandoc-templates.org) 100+ community-contributed templates organized by output format and document type: - **Academic**: dissertations, theses, articles - **Professional**: CVs, cover letters, invoices - **Presentations**: reveal.js, PPTX - **Creative**: novels, manuscripts, poetry ### Notable Templates | Template | Stars | Use case | |---|---|---| | [Eisvogel](https://github.com/Wandmalfarbe/pandoc-latex-template) | 7k+ | Clean LaTeX→PDF; lecture notes, CS exercises | | CV Boilerplate | — | Professional CV from structured Markdown | | Invoice Boilerplate | — | Automated invoices | ## References - https://pandoc.org/MANUAL.html#templates - https://pandoc-templates.org/ ## Related - [[Pandoc]] - [[Pandoc plugin for Obsidian]]