Site Configuration
Site configuration is where you define global settings for your VitePress site. The config file is located at.vitepress/config.js (or .ts, .mjs, .mts) and controls everything from metadata to build options.
Basic Setup
Config File Location
VitePress looks for your configuration file at:.js, .ts, .mjs, .mts
Using defineConfig
ThedefineConfig helper provides TypeScript-powered intellisense:
TypeScript is supported out of the box - no additional configuration needed.
Dynamic Configuration
You can export an async function for dynamic configuration:await:
Site Metadata
title
string
default:"VitePress"
The title for your site. Displayed in the nav bar and used as the suffix for page titles.
# Hello, the page title becomes:
titleTemplate
string | boolean
Customize the page title suffix or format. Use
:title as a placeholder for the page title.false to disable title suffixes:
description
string
default:"A VitePress site"
Site description. Renders as a
<meta> tag in the page HTML.lang
string
default:"en-US"
The language attribute for the site. Renders as
<html lang="...">.head
HeadConfig[]
default:"[]"
Additional elements to render in the
<head> tag.Add a Favicon
Add Google Fonts
Add Analytics
Directory Structure
base
string
default:"/"
The base URL for deployment. Required when deploying to a subdirectory.
srcDir
string
default:"."
The directory where your markdown pages are stored, relative to project root.
outDir
string
default:"./.vitepress/dist"
The build output location, relative to project root.
assetsDir
string
default:"assets"
Directory to nest generated assets under. Must be inside
outDir.cacheDir
string
default:"./.vitepress/cache"
Directory for cache files, relative to project root.
srcExclude
string[]
Glob patterns for markdown files to exclude from source content.
Routing
cleanUrls
boolean
default:"false"
Remove trailing
.html from URLs.rewrites
Record<string, string>
Define custom directory to URL mappings.
Theming
appearance
boolean | 'dark' | 'force-dark' | 'force-auto' | UseDarkOptions
default:"true"
Control dark mode behavior.
- Auto (Default)
- Dark by Default
- Force Dark
- Force Auto
- Advanced
scrollOffset
number | string | string[] | { selector: string | string[]; padding: number }
default:"134"
Configure scroll offset for sticky headers.
Build Options
ignoreDeadLinks
boolean | 'localhostLinks' | (string | RegExp | Function)[]
default:"false"
Control how dead links are handled during build.
- Ignore All
- Ignore Localhost
- Pattern Matching
lastUpdated
boolean
default:"false"
Get last updated timestamp for each page using Git.
mpa (Experimental)
boolean
default:"false"
Build in MPA mode (Multi-Page Application). Ships 0kb JavaScript but disables client-side navigation.
metaChunk (Experimental)
boolean
default:"false"
Extract page metadata to separate JavaScript chunks for better caching.
buildConcurrency (Experimental)
number
default:"64"
Configure build concurrency. Lower values reduce memory usage but increase build time.
Integrations
vite
ViteConfig
Pass configuration to the internal Vite dev server/bundler.
vue
VuePluginOptions
Pass options to
@vitejs/plugin-vue.markdown
MarkdownOptions
Configure Markdown-it parser and Shiki syntax highlighting.
Build Hooks
buildEnd
(siteConfig: SiteConfig) => Awaitable<void>
Hook called after build finishes but before CLI process exits.
postRender
(context: SSGContext) => Awaitable<SSGContext | void>
Hook called when SSG rendering is done. Handle teleports content.
transformHead
(context: TransformContext) => Awaitable<HeadConfig[]>
Transform head before generating each page. Return extra head entries to merge.
transformHtml
(code: string, id: string, context: TransformContext) => Awaitable<string | void>
Transform HTML content before saving to disk.
transformPageData
(pageData: PageData, context: TransformPageContext) => Awaitable<Partial<PageData>>
Transform page data for each page. Can directly mutate or return values to merge.
Advanced Features
Config Extension
UserConfig
Extend another configuration file.
Sitemap Generation (Experimental)
SitemapStreamOptions & { hostname: string }
Configure automatic sitemap generation.
Content Props
Record<string, any>
Props to pass to the content component.
Router Configuration
{ prefetchLinks?: boolean }
Configure router behavior.
TypeScript Configuration
Custom Theme Config Type
For custom themes, usedefineConfig with a generic type:
Environment-Specific Config
Access command and mode via function config:Next Steps
Theme Configuration
Configure the default theme’s appearance and behavior
Custom Theme
Create a completely custom theme
Extending Default Theme
Customize the default theme with slots and overrides