YAML Front Matter: Metadata at the Top of a Markdown File
Front matter is a block of YAML at the very top of a Markdown file, opened and closed by a line of three dashes (---). Static site generators read it as the page's data, such as title, date, layout and tags, then render everything below the closing line as the page content.
| Generator | Formats | Fields it reads itself |
|---|---|---|
| Jekyll | YAML between --- | layout, permalink, published; on posts: date, category, categories, tags |
| Hugo | YAML (---), TOML (+++), JSON ({ }) | title, date, draft, description, slug, weight, tags |
| Eleventy | YAML by default, plus ---json and ---js | permalink, layout, tags |
| Astro | YAML or TOML | layout (for Markdown pages in src/pages) |
Updated
Front matter turns a plain Markdown file into a page with metadata, and a single misplaced dash breaks it. Paste a file into the splitter to see exactly where the metadata ends and the content starts, and which top-level fields it found, before your build complains.
Front matter splitter
Paste a Markdown file. The splitter finds the front matter block, lists its simple top-level fields and shows the body that will be rendered.
Front matter found and closed.
Front matter examples
A blog post (YAML)
A typical post: quoted title because it contains a colon, a date, a list of tags and a custom author field.
---
title: "Sourdough: a beginner's starter"
description: Feed it daily for a week before baking.
date: 2026-10-20
tags:
- baking
- guides
author: Ana Ruiz
---
Mix equal weights of flour and water in a clean jar...The same post with TOML front matter (Hugo)
Hugo reads +++ as TOML front matter. Custom values sit under the params key.
+++
title = "Sourdough: a beginner's starter"
date = 2026-10-20
draft = false
tags = ["baking", "guides"]
[params]
author = "Ana Ruiz"
+++
Mix equal weights of flour and water in a clean jar...
The delimiter rules
Jekyll's documentation puts it plainly: front matter must be the first thing in the file and must be valid YAML set between triple-dashed lines. Other generators follow the same shape.
Inside the block, normal YAML applies. Indent with spaces, quote values with special characters and use lists for tags and categories.
Fields worth setting on every page
A title and a description cover the page heading and the search snippet in most themes. A date orders posts, and draft or published decides whether the page is built at all.
Everything else is up to your templates. Any field you add becomes data the layout can print, such as an author name, a hero image path or a reading time.
How it works
- Paste a Markdown file, or edit the sample post.
- The splitter checks that the very first line is --- (YAML) or +++ (TOML) and looks for the matching closing line.
- It shows the front matter block, the simple top-level fields it found and the body that will be rendered.
- If the block is never closed, it tells you, which is the most common cause of a page rendering its metadata as text.
Tips
- Nothing may come before the opening ---, not even a blank line or a byte order mark, or most generators treat the block as ordinary text.
- Quote titles that contain a colon followed by a space, such as "Pricing: what changed", or YAML reads them as a nested mapping.
- Write dates as YYYY-MM-DD so generators and YAML libraries agree on what they mean.
- Keep custom fields in one consistent place. Hugo, for example, has a params key meant for your own values.
Frequently asked questions
What is front matter in Markdown?
It is metadata written at the top of a Markdown file between two delimiter lines. Markdown itself does not define it; static site generators and content tools agreed on the convention and read it as data before rendering the rest.
Does front matter have to be YAML?
YAML is the common default, but not the only option. Hugo accepts TOML between +++ lines and JSON in braces, Eleventy supports ---json and ---js, and Astro accepts TOML as well.
Why does my page show the front matter as text?
Usually something sits before the first ---, the closing --- is missing, or the opening line has extra characters. The splitter above flags the last two straight away.
Can front matter be empty?
Yes. In Jekyll an empty pair of --- lines still marks the file for processing, which is how CSS or feed files get Liquid tags rendered without any metadata.
How do I read front matter in my own code?
Split the file at the delimiters, parse the first part with a YAML library and pass the rest to your Markdown renderer. Eleventy does this with the gray-matter package, which you can also use directly in Node.
Related: Markdown cheat sheet, Static site generators, YAML comments, TOML vs YAML, Markdown to HTML.
Build your site free or see all free tools. On We.Inc you can build your site free, with no card and no trial needed to start. AI building is on paid plans from $19 a month.
More in Guides
- YAML Multiline Strings: | and >, Explained with a Live Preview
- YAML vs JSON: Which One, and Why
- Your Connection Is Not Private: Causes and Fixes
- 400 Bad Request: What Was Wrong With the Request
- 401 vs 403: Pick the Right Status for a Refused Request
- 403 Forbidden: Why the Server Refuses and How to Fix It
- 404 Not Found: Why Pages Go Missing and How to Fix It
- 404 Page Examples: 20 Designs With Copy-Paste Code
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App