All skills
antfu avatar

/vitepress

@d02c484 official
by Anthony Fuantfu/skills5.9k stars
335

VitePress static site generator powered by Vite and Vue. Use when building documentation sites, configuring themes, or writing Markdown with Vue components.

Use this Skill: https://skilld.dev/gh/antfu/skills/vitepress

This session only. Nothing lands on disk.

referencescore-routing.md

≈1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Routing

VitePress uses file-based routing where markdown files map directly to HTML pages.

File to URL Mapping

.
├─ index.md           →  /index.html (/)
├─ about.md           →  /about.html
├─ guide/
│  ├─ index.md        →  /guide/index.html (/guide/)
│  └─ getting-started.md → /guide/getting-started.html

Project Structure

.
├─ docs                    # Project root
│  ├─ .vitepress          # VitePress directory
│  │  ├─ config.ts        # Configuration
│  │  ├─ theme/           # Custom theme
│  │  ├─ cache/           # Dev server cache (gitignore)
│  │  └─ dist/            # Build output (gitignore)
│  ├─ public/             # Static assets (copied as-is)
│  ├─ index.md            # Home page
│  └─ guide/
│     └─ intro.md

Source Directory

Separate source files from project root:

// .vitepress/config.ts
export default {
  srcDir: './src'  // Markdown files live in ./src/
}

With srcDir: 'src':

.
├─ .vitepress/           # Config stays at project root
└─ src/                  # Source directory
   ├─ index.md          →  /
   └─ guide/intro.md    →  /guide/intro.html

Linking Between Pages

Use relative or absolute paths. Omit file extensions:

<!-- Recommended -->
[Getting Started](./getting-started)
[Guide](/guide/)

<!-- Works but not recommended -->
[Getting Started](./getting-started.md)
[Getting Started](./getting-started.html)

Clean URLs

Remove .html extension from URLs (requires server support):

export default {
  cleanUrls: true
}

Server requirements:

  • Netlify, GitHub Pages: Supported by default
  • Vercel: Enable cleanUrls in vercel.json
  • Nginx: Configure try_files $uri $uri.html $uri/ =404

Route Rewrites

Customize the mapping between source and output paths:

export default {
  rewrites: {
    // Static mapping
    'packages/pkg-a/src/index.md': 'pkg-a/index.md',
    'packages/pkg-a/src/foo.md': 'pkg-a/foo.md',
    
    // Dynamic parameters
    'packages/:pkg/src/:slug*': ':pkg/:slug*'
  }
}

This maps packages/pkg-a/src/intro.md → /pkg-a/intro.html.

Important: Relative links in rewritten files should be based on the rewritten path, not the source path.

Rewrites can also be a function:

export default {
  rewrites(id) {
    return id.replace(/^packages\/([^/]+)\/src\//, '$1/')
  }
}

Public Directory

Files in public/ are copied to output root as-is:

docs/public/
  ├─ favicon.ico     →  /favicon.ico
  ├─ robots.txt      →  /robots.txt
  └─ images/logo.png →  /images/logo.png

Reference with absolute paths:

![Logo](/images/logo.png)

Base URL

For sub-path deployment (e.g., GitHub Pages):

export default {
  base: '/repo-name/'
}

Set base: './' for a relocatable build (v2): pages reference everything relative to their own location, so the same output works from any sub-path or file:// without rebuilding. Keep cleanUrls off when doing this.

All absolute paths are automatically prefixed with base. For dynamic paths in components, use withBase:

<script setup>
import { withBase } from 'vitepress'
</script>

<template>
  <img :src="withBase('/logo.png')" />
</template>

Key Points

  • index.md files map to directory root (/guide/ instead of /guide/index)
  • Use paths without extensions in links for flexibility
  • srcDir separates source from config
  • cleanUrls removes .html but requires server support
  • rewrites enables complex source structures with clean output URLs
  • base: './' produces a relocatable build that runs from any path or file://
  • Dynamic routes: wrap .paths.ts loaders with defineRoutes for type hints (see dynamic-routes)
<!-- Source references: - https://vitepress.dev/guide/routing - https://vitepress.dev/guide/asset-handling -->

Source: SKILL.md on GitHub

No alerts2d5 checks · Risk SAFE
  • Gen Agent Trust Hub2d

    The skill provides comprehensive documentation and configuration examples for VitePress, a static site generator. No malicious patterns or intent were detected. A minor surface for indirect prompt injection was identified due to the documented features for ingesting external data during the site build process, which is inherent to the framework's functionality.

  • Socket2d

    No alerts

  • Snyk2d

    Risk: LOW · No issues

  • Runlayer7mo

    2/16 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at d02c484. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 days ago.

Activeupdated 4 days ago
Other metadata
metadata
{
  "author": "Anthony Fu",
  "version": "2026.9.25",
  "source": "Generated from https://github.com/vuejs/vitepress, scripts located at https://github.com/antfu/skills"
}

README badge

README badge for antfu/skills/vitepress

VitePress is a static site generator built on Vite and Vue 3 that converts Markdown files into a fast single-page application, with file-based routing and built-in support for Vue components directly in Markdown. Use it for documentation sites, blogs, and marketing pages where you need configurable themes, syntax-highlighted code blocks, and instant hot-reload during development.

Generated from the current SKILL.md.

Does VitePress work with Vue components embedded in Markdown?
Yes. Vue components work directly in Markdown files, and you can use script setup and directives within Markdown content.
Can I build a multi-language documentation site with VitePress?
Yes. VitePress includes internationalization support with locale configuration for building multi-language sites.
What search options does VitePress provide?
VitePress includes built-in local search or integration with Algolia for full-text search across documentation.
Can I customize the default theme or build a custom one from scratch?
Yes. You can extend the default theme via CSS variables and slots, or build a completely custom theme by implementing the theme interface.
Does VitePress support dynamic route generation?
Yes. You can generate pages from data at build time using createContentLoader and paths loader files for dynamic routing.

Generated from the current SKILL.md. These answers refresh after source changes.