VitePress-Specific Features
VitePress extends standard markdown with powerful features for documentation sites.
Frontmatter
Add metadata to your pages using YAML frontmatter:
markdown
---
title: Page Title
description: Page description for SEO
layout: doc
---
# Page ContentCommon Frontmatter Options
yaml
---
title: Custom Page Title
description: Custom description
layout: doc | home | page
navbar: true | false
sidebar: true | false
aside: true | false | left
outline: [2, 3]
---Custom Layouts
Home Layout
markdown
---
layout: home
hero:
name: Project Name
text: Tagline goes here
tagline: A longer description
actions:
- theme: brand
text: Get Started
link: /guide/getting-started
- theme: alt
text: View on GitHub
link: https://github.com/username/repo
features:
- title: Feature 1
details: Description of feature 1
- title: Feature 2
details: Description of feature 2
---Page Layout
markdown
---
layout: page
---
Custom page content without sidebar.Internal Links
VitePress automatically handles internal links:
markdown
[Getting Started](../guide/getting-started.md)
[Customization](../guide/customization)
[Home](/)Asset Handling
Public Assets
Place assets in docs/public/:
markdown
Relative Assets
Use relative paths for assets next to markdown files:
markdown
Code Groups
Display multiple code examples with tabs:
javascript
const greeting = "Hello, World!"
console.log(greeting)typescript
const greeting: string = "Hello, World!"
console.log(greeting)python
greeting = "Hello, World!"
print(greeting)Import Code Snippets
Import code from files:
markdown
<<< @/path/to/file.jsWith line highlighting:
markdown
<<< @/path/to/file.js{2,4-6}With specific lines:
markdown
<<< @/path/to/file.js#region-nameBadges
infotipwarningdangerTeam Page
Create a team page with member cards:
markdown
---
layout: page
---
<script setup>
import { VPTeamMembers } from 'vitepress/theme'
const members = [
{
avatar: 'https://github.com/username.png',
name: 'Member Name',
title: 'Role',
links: [
{ icon: 'github', link: 'https://github.com/username' }
]
}
]
</script>
# Our Team
<VPTeamMembers :members="members" />Last Updated
Enable last updated timestamp in frontmatter:
yaml
---
lastUpdated: true
---Configure in config.mts:
typescript
export default defineConfig({
lastUpdated: true
})Search
VitePress includes built-in local search. Configure in config.mts:
typescript
export default defineConfig({
themeConfig: {
search: {
provider: 'local'
}
}
})Sidebar Configuration
Auto Sidebar
Use the included sidebar generator:
typescript
import { set_sidebar } from "../utils/auto-gen-sidebar.mjs"
export default defineConfig({
themeConfig: {
sidebar: set_sidebar("docs/guide")
}
})Manual Sidebar
typescript
sidebar: {
'/guide/': [
{
text: 'Guide',
items: [
{ text: 'Getting Started', link: '/guide/getting-started' },
{ text: 'Customization', link: '/guide/customization' }
]
}
]
}Multi-Sidebar
Different sidebars for different sections:
typescript
sidebar: {
'/guide/': [/* guide sidebar */],
'/api/': [/* api sidebar */],
'/examples/': [/* examples sidebar */]
}Edit Link
Add "Edit this page" links:
typescript
export default defineConfig({
themeConfig: {
editLink: {
pattern: 'https://github.com/username/repo/edit/main/docs/:path',
text: 'Edit this page on GitHub'
}
}
})Social Links
Configure in site.config.js:
javascript
theme: {
socialLinks: [
{ icon: 'github', link: 'https://github.com/username/repo' },
{ icon: 'twitter', link: 'https://twitter.com/username' },
{ icon: 'discord', link: 'https://discord.gg/invite' }
]
}Footer
Add a footer in config.mts:
typescript
export default defineConfig({
themeConfig: {
footer: {
message: 'Released under the MIT License.',
copyright: 'Copyright © 2024-present Your Name'
}
}
})Next Steps
- Explore VitePress documentation
- Check out Vue.js for component examples
- Learn about Vite for build configuration