Definition
What it is
Frontmatter sits above the content, separated by a fixed delimiter. In Jekyll, Hugo, Eleventy and Astro, the delimiter is three hyphens:
---
title: Writing a slug
date: 2024-03-15
tags: [web, seo]
---
In TOML-based systems (Hugo's +++) or JSON ({...} at the top), the shape differs but the principle is the same: a machine-readable block that describes what follows. The content below is prose; the frontmatter above is a contract.
Why it matters
Without frontmatter, a static site generator must parse the prose to find the title, the date and the tags. Parsing prose is brittle: markdown headings, first paragraphs, and regex all fail on the same edge cases (nested quotes, escaped characters, mixed languages). Frontmatter fixes the shape: the metadata is declared once, in a predictable format, at a predictable position.
YAML vs TOML vs JSON
Aspect | YAML | TOML | JSON | |
|---|---|---|---|---|
Delimiter |
|
|
| |
Typical tool | Jekyll, Eleventy, Astro | Hugo | Custom | |
Readability | High | High | Low (quotes, braces) | |
Indentation | Significant | Not significant | Required | |
Multi-line strings | `\ |
|
| Escape |
Best for | Hand-edited config | Config-heavy sites | Machine output |
Where frontmatter lives
graph LR F[Frontmatter] -->|delimiter| B[Body] F --> M[Metadata: title, date, tags] B --> R[Rendered HTML] M --> I[Indexes, feeds, sitemaps] style F fill:#FFF3E0 style B fill:#E8F5E9
How to write frontmatter well
Frontmatter that stays sane
Three hyphens, on their own lines
The delimiter is
---at the beginning of a line. Not---inline. Not---yaml.Lowercase keys
title,date,tags. NotTitleorTITLE. Consistency beats cleverness.ISO 8601 dates
2024-03-15T10:00:00-05:00. Ambiguous dates break on server timezone changes.Validate the schema
A frontmatter with the wrong type (string where array expected) fails at build time, hours after commit. Validate on save.
Common failures
Origin
In book production, front matter is everything before the main text: half-title, title page, copyright, dedication, table of contents, preface, acknowledgements. It is not the body; it describes the body. Static site generators of the 2000s (Jekyll was the first to popularise the pattern, in 2008) borrowed the word: a short block of metadata above the content, describing it.
Jekyll uses a front matter block at the top of files to define variables, like the layout to use, the title, the date.
— Jekyll documentation, *Front Matter*, 2024
Evidence
FAQ
- Why YAML and not TOML?
YAML is more readable for hand editing and has a wider ecosystem. TOML is stricter but less expressive for nested structures.
- Can I mix YAML and TOML?
In Hugo, yes, per file. In most other tools, pick one. Mixing within a project is a configuration trap.
- How do I handle a value with a colon?
Quote it:
title: "Writing: a slug".- What if I need to put code in frontmatter?
Don't. Frontmatter is for metadata. Code goes in the body, or in a fenced block.
Connections
- metadata
- yaml
- static-site-generator
- markdown
- schema
Jekyll (2024). Front Matter. https://jekyllrb.com/docs/front-matter/
Hugo (2024). Front Matter. https://gohugo.io/content-management/front-matter/
Astro (2024). Content Collections. https://docs.astro.build/en/guides/content-collections/
Etymology
Origin: borrowed
front(noun): from Latin frons, frontis, "forehead, front"matter(noun): from Latin materia, "material, subject"
Semantic network
● broader ● narrower ● related
Used in the garden
Sources
Jekyll (2024). Front Matter. https://jekyllrb.com/docs/front-matter/
Hugo (2024). Front Matter. https://gohugo.io/content-management/front-matter/
Astro (2024). Content Collections. https://docs.astro.build/en/guides/content-collections/