搜索 K
主题
VitePress 是面向技术文档与知识博客的轻量框架,核心优势是“Vite 速度 + Markdown 友好 + 足够灵活的主题扩展”。
适合:
不适合:
| 能力 | 表现 | 说明 |
|---|---|---|
| Markdown 体验 | 强 | 开箱顺手,语法支持完善 |
| 构建性能 | 强 | Vite 驱动,开发反馈快 |
| 导航管理 | 中高 | 配置灵活,但大型站需更强规范 |
| 搜索 | 中高 | 本地搜索可用,外部搜索可扩展 |
| i18n | 中高 | 官方支持多语言站点 |
| 版本化 | 中 | 通常依赖目录和发布策略 |
| 主题扩展 | 中高 | 可扩展但不过度复杂 |
| 维护成本 | 中低 | 低于重型平台方案 |
docs/.vitepress/config.*.vitepress/dist)vitepress dev docsvitepress build docsvitepress preview docsproject/
docs/
index.md
guides/
start.md
architecture.md
reference/
cli.md
config.md
blog/
2026-03-doc-frameworks.md
.vitepress/
config.mts
theme/
index.ts
custom.css建议:
guides 与 reference 分离.vitepress/theme/import { defineConfig } from "vitepress";
export default defineConfig({
title: "Engineering Notes",
description: "Public learning notes",
lang: "zh-CN",
lastUpdated: true,
cleanUrls: true,
markdown: {
lineNumbers: true,
},
themeConfig: {
logo: "/logo.svg",
nav: [
{ text: "首页", link: "/" },
{ text: "指南", link: "/guides/start" },
{ text: "博客", link: "/blog/2026-03-doc-frameworks" },
],
sidebar: {
"/guides/": [
{
text: "指南",
items: [
{ text: "快速开始", link: "/guides/start" },
{ text: "架构设计", link: "/guides/architecture" },
],
},
],
"/reference/": [
{
text: "参考",
items: [
{ text: "CLI", link: "/reference/cli" },
{ text: "配置", link: "/reference/config" },
],
},
],
},
search: {
provider: "local",
},
socialLinks: [{ icon: "github", link: "https://github.com/your-org/your-repo" }],
},
});关键点:
cleanUrls 对 URL 可读性和 SEO 友好sidebar 分区写法更利于大型内容管理---
title: VitePress 选型与实践
description: 面向博客与文档的一体化方案
outline: deep
lastUpdated: true
tags: [vitepress, docs]
---/zh/、/en/VitePress 无强内建版本化,可采用:
/v1/、/v2/v1.docs.example.comtheme/custom.css 做样式增强theme/index.ts 注入布局组件components/ 并加文档name: vitepress
on:
push:
branches: [main]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm docs:build目录增长后侧边栏失控
做法:分区管理并冻结顶层结构。
组件滥用导致维护成本上升
做法:组件仅用于复用和必要交互。
搜索相关性差
做法:统一标题命名、补齐摘要和标签。
VitePress 的优势在于“足够强大,同时不过度复杂”。如果你希望把文档与博客统一,并保持高构建效率和良好可维护性,它是非常均衡的选择。