THE GITHTML FIELD GUIDE
Maintain a Pandoc HTML template without losing document content
Start from the installed Pandoc version's default template, change only what the document needs, and test a representative fixture after each edit. Preserve the fields required to emit the body and metadata. A template controls output structure, so a valid conversion can still produce an incomplete or misleading document if important variables or conditional blocks are removed.
Treat the template as executable publishing configuration
A template is not simply a static HTML file with a few labels changed. It contains placeholders and conditions that determine which parts of the converted document appear. Before customizing it, identify the requirements that the default output does not meet. Keep the list narrow: perhaps a project identity, a review-status line, or a particular placement for the contents list. Avoid copying a large anonymous template without understanding its assumptions. Record the Pandoc version used as the starting point and keep the customized template with the source repository so another maintainer can inspect and reproduce the transformation.
Make a minimal change and test the full feature fixture
The first command below prints the default template for inspection; it does not overwrite a project file. Save and edit an approved copy through your normal local editing workflow, then use it explicitly during conversion. Test a fixture with a title, headings, code, links, and any bibliography or contents features your project relies on. Change one template concern at a time so a missing section is easy to trace. Do not assume that a page opening successfully proves all variables were preserved. Search for distinctive body text and compare the beginning and end of the output with the source.
pandoc --print-default-template=html5
pandoc fixture.md --standalone --template=templates/review.html \
--metadata title="Template fixture" --output=fixture.htmlReview upgrades as template compatibility changes
When updating Pandoc, compare your custom template with the new default and examine relevant release guidance. The right response is not automatically to replace your template; first identify what changed and whether your required features are affected. Re-run the same fixture and check metadata, visible content, navigation, and any accessibility-relevant structure. Keep styling changes separate from semantic template repairs where practical. If a custom field is required, document how authors supply it and what happens when it is missing. A small maintained template with explicit tests is easier to trust than a visually elaborate export whose omissions are discovered only after sharing. Have a second reviewer inspect the template diff independently of the visual preview. Missing conditional branches may remain invisible until a later document supplies the metadata that activates them.
- Write the unmet output requirements before changing the template.
- Inspect the installed default and maintain a reviewed project copy.
- Test distinctive content at the beginning and end, plus all required optional features.
- Re-run the fixture and compare defaults when upgrading the converter.
Sources and further reading
AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.