Aller au contenu
uencoder

Guide Frontmatter (YAML/TOML/JSON)

Référence pour frontmatter metadata blocks utilisé en Markdown et static site generators.

Format Variants

YAML frontmatter is delimited by --- lines and is the most common format. TOML frontmatter uses +++ delimiters and offers stricter typing. JSON frontmatter uses curly braces and is fully standardized. The frontmatter block appears at the top of a content file, before the body. Static site generators parse frontmatter to extract metadata like title, date, and tags.

YAML
--- delimited
most common
TOML
+++ delimited
stricter typing
JSON
Brace delimited
fully standard

Parsing and Usage

Frontmatter parsers split the file at the delimiter and parse the metadata block separately. Common fields include title, date, tags, categories, draft status, and custom metadata. Astro, Hugo, Jekyll, and Next.js all support frontmatter. The metadata is available in templates and for content queries. Invalid frontmatter causes build failures, so validation is important.

parsing
Split and parse metadata
before body
common fields
title, date, tags
draft, layout
SSG support
Astro, Hugo, Jekyll
Next.js, Gatsby

Outils associés

参考链接