Skip to main content

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:
Frontmatter must be at the very top of the file, before any elements including <script> tags.

Accessing Frontmatter Data

In Markdown

Access frontmatter via the $frontmatter global:

In Vue Components

Use the useData() 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.
  • If title is set, it’s used as the page title
  • Combined with titleTemplate to generate the full <title> tag
  • Example: API Reference | My Docs

titleTemplate

Type: string | boolean Customize the title suffix or format for this page:
Result: API Reference | Developer Docs

description

Type: string Page description for SEO. Renders as a <meta> tag:
Generates:
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:
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. Type: boolean
Default: true
Show or hide the navigation bar on this page:
Type: boolean
Default: true
Show or hide the sidebar on this page:
Useful for landing pages or full-width content.

aside

Type: boolean | 'left'
Default: true
Control the table of contents aside component:

outline

Type: number | [number, number] | 'deep' | false
Default: 2
Control which heading levels appear in the outline:
Shows h2 and h3 headings

lastUpdated

Type: boolean | Date
Default: true
Control the last updated timestamp display:
When true, VitePress uses Git commit timestamps. When a Date is provided, it’s displayed instead.
Type: boolean
Default: true
Show or hide the edit link in the page footer:
Type: boolean
Default: true
Show or hide the footer on this page:

pageClass

Type: string Add custom CSS classes to the page wrapper:
Then style in your theme:

isHome

Type: boolean Force home page elements in custom layouts:
This is primarily used internally. Most users won’t need this field.

Custom Frontmatter Fields

Define your own frontmatter fields for custom functionality:
Access custom fields in components:

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.
For a complete list of default theme frontmatter options, see the Frontmatter Config Reference.