Frontmatter Configuration
Frontmatter enables page-based configuration in VitePress. Every markdown file can use YAML frontmatter to override site-level or theme-level options.Usage
VitePress parses YAML frontmatter using gray-matter. Place frontmatter at the top of your markdown file:Accessing Frontmatter Data
In Markdown
Access frontmatter via the$frontmatter global:
In Vue Components
Use theuseData() helper in <script setup>:
Site Configuration Fields
These fields override site-level configuration for individual pages.title
Type:string
Title for the page. Overrides the site-level title.
How Title Generation Works
How Title Generation Works
- If
titleis set, it’s used as the page title - Combined with
titleTemplateto generate the full<title>tag - Example:
API Reference | My Docs
titleTemplate
Type:string | boolean
Customize the title suffix or format for this page:
- Custom Suffix
- Custom Format
- Disable Suffix
API Reference | Developer Docsdescription
Type:string
Page description for SEO. Renders as a <meta> tag:
head
Type:HeadConfig[]
Inject additional tags into the <head> section:
The
HeadConfig type is defined as:Default Theme Fields
These options are specific to VitePress’s default theme.layout
Type:'doc' | 'home' | 'page'Default:
'doc'
Determines the page layout:
- doc
- home
- page
Standard documentation layout with:
- Sidebar navigation
- Table of contents
- Edit link
- Last updated timestamp
hero
For home layout only Define the hero section on home pages. See Default Theme: Home Page for all options.features
For home layout only Define feature items on home pages. See Default Theme: Home Page for all options.navbar
Type:booleanDefault:
true
Show or hide the navigation bar on this page:
sidebar
Type:booleanDefault:
true
Show or hide the sidebar on this page:
aside
Type:boolean | 'left'Default:
true
Control the table of contents aside component:
outline
Type:number | [number, number] | 'deep' | falseDefault:
2
Control which heading levels appear in the outline:
- Single Level
- Range
- Deep
- Disable
lastUpdated
Type:boolean | DateDefault:
true
Control the last updated timestamp display:
When
true, VitePress uses Git commit timestamps. When a Date is provided, it’s displayed instead.editLink
Type:booleanDefault:
true
Show or hide the edit link in the page footer:
footer
Type:booleanDefault:
true
Show or hide the footer on this page:
pageClass
Type:string
Add custom CSS classes to the page wrapper:
isHome
Type:boolean
Force home page elements in custom layouts:
Custom Frontmatter Fields
Define your own frontmatter fields for custom functionality:Alternative Formats
VitePress also supports JSON frontmatter:TypeScript Support
Define types for custom frontmatter:Best Practices
1
Be Consistent
Use consistent frontmatter structure across similar pages:
2
Optimize for SEO
Always include
title and description for better search rankings:3
Use Meaningful Defaults
Set sensible site-level defaults, override only when needed:
4
Document Custom Fields
Maintain a reference for custom frontmatter fields your team uses
Reference Implementation
Frontmatter parsing is handled by the
@mdit-vue/plugin-frontmatter package. See src/node/markdown/markdown.ts:344 for integration details.