Frontmatter
Frontmatter 是置于文档开头的 YAML/TOML/JSON 元数据块,以 --- 分隔,常用于静态站点生成器。
用途
在 Markdown 等正文前附加结构化元数据,便于站点生成与内容管理。
机制
文档以 --- 开头,后接 YAML(或 TOML/JSON)元数据,再以 --- 结束,之后为正文。解析器分离 frontmatter 与正文。Jekyll/Hugo/Astro 等广泛使用。
用例
- Astro/Hugo/Jekyll 文章元数据
- Markdown 博客文章 frontmatter
- 文档站点配置
- CMS 内容管理
示例
- 输入
--- title: Hello --- # Body输出meta {title:"Hello"} + bodyYAML frontmatter
常见错误
- A frontmatter syntax error breaks parsing
- Check it with a validator for the corresponding format