5.3 KiB
Front Matter And Content Rules
Front Matter Policy
Default to YAML front matter in the output unless the user explicitly asks to strip metadata.
Preserve fields when they still carry meaning in the destination:
titlelinkTitledescriptiondatepublishDatelastmodexpiryDatedraftaliasesslugurlweightcategorieskeywordsparamsmenusor menu-like data
Do not invent fields that were not present.
If the repository mixes casing for reserved Hugo fields, normalize to the documented canonical form in the output:
Title->titleDescription->descriptionLinkTitle->linkTitle
Apply this normalization before using front matter to build lists, tables, or link labels. Preserve unknown custom keys with their original spelling unless the user asks for a schema rewrite.
Effective Value Rules
Do not treat front matter as a flat key-value copy problem. In Hugo, some visible values are inferred from configuration, aliases, filenames, or Git metadata.
For the source site, check any site-specific front matter documentation and the local [frontmatter] config before deciding which value is authoritative.
Important alias rules:
publishDatecan come frompublishdate,pubdate, orpublishedlastmodcan come fromlastmodormodifiedexpiryDatecan come fromexpirydateorunpublishdate
Important token rules:
:defaultmeans Hugo falls back through the documented default date sequence:filenamecan derivedateand sometimesslugfrom a date-prefixed filename:fileModTimecan supply a date from the file modification time:gitcan supply a date from Git history when enabled
Conversion guidance:
- Preserve explicit source fields when they are already concrete and meaningful.
- If the repository relies on alias or token resolution, do not mistakenly drop related metadata just because the canonical key is absent.
- If you can deterministically resolve a derived date or slug from the local snapshot and the user wants flattened output, materialize it explicitly.
- If deterministic resolution would require Git state, build execution, or missing metadata, keep the source field plus a short conversion note instead of guessing.
Resources Metadata
Front matter may also describe page resources, not just page metadata.
Preserve resources metadata when it affects:
- image or file labels
- resource lookup by
Name - titles used in generated link text
- custom
params - wildcard-driven assignments
In Hugo's page resource rules, matching order matters and name and title can use the :counter placeholder. Do not simplify these structures away unless the destination explicitly does not need them.
Archetype Signal
Read archetypes before normalizing front matter. In a typical Hugo docs site:
archetypes/default.mdestablishes the common fieldsarchetypes/functions.mdadds nestedparams.functions_and_methodsarchetypes/methods.mdfollows the same method metadata patternarchetypes/glossary.mdandarchetypes/news.mdintroduce content-type-specific fields
When an archetype or local content convention introduces nested fields, preserve the shape unless the user asks for a simplified schema.
Content Composition Rules
The page file is not always the full source of truth. Also check:
- shared
_commoncontent fragments - shortcode-generated prose
- data-backed shortcode inputs from
data/* - generated example source files referenced by local shortcodes
- render-hook-driven link behavior
- page bundle resources and section resources
- page resource metadata from the page's own front matter
- front matter configuration that changes how dates, slugs, and publish status are derived
Literal Examples Versus Live Syntax
Preserve literal Hugo examples when they are:
- inside fenced code blocks
- clearly escaped with comment markers such as
/* ... */ - part of tutorial prose explaining Hugo syntax
Important escaped forms to preserve:
{{</* foo */>}}{{%/* foo */%}}- notation examples that compare
%and<shortcode forms in tables or inline code
Do not treat those as active shortcode invocations merely because they are outside fenced code blocks.
Convert live syntax when it changes the rendered page.
Explicit Downgrade Policy
When a local shortcode cannot be materialized safely:
- remove the live Hugo syntax
- replace it with a short Markdown explanation
- keep any safe subset of content that is already visible in the page source
Examples:
- preserve inline Redis CLI text even if a multi-language tabset cannot be rebuilt
- preserve a resolved image URL even if the surrounding presentation wrapper is custom
- preserve section purpose and emit a note if a build-time data table cannot be reconstructed
Markdown Features To Preserve
Keep these when possible:
- fenced code blocks
- tables
- blockquotes
- definition lists if the destination Markdown flavor supports them
- math passthrough delimiters when the destination supports math
- block attributes only when the destination flavor supports them
- heading attributes such as
## Heading {#id .class} - code fence attributes and highlighting options when the destination flavor supports them
If the destination does not support a feature, downgrade explicitly instead of dropping content.