部署
使用 npx gem-book build docs 将网站构建到 dist/web,然后为该目录提供静态服务即可,不需要配置重写规则:
- 每个页面都预渲染成自己的
index.html,例如dist/web/guide/index.html 404.html是找不到路径时的页面,GitHub Pages、Netlify、Vercel 等会自动使用 是使用重定向 <meta http-equiv="refresh">跳转的页面dist/web/static中的脚本和样式文件名中有哈希,可以长时间缓存llms.txt给 LLM 列出所有页面,llms-full.txt包含所有页面的内容,每个页面也有展开了插件的 Markdown 版本,例如dist/web/guide.md,多语言时它们在语言目录中,根目录中的是默认语言的;只包括最新版本- 配置了
时会生成sitesitemap.xml - 页面有
<link rel="canonical">和其他语言的<link rel="alternate" hreflang>,描述来自description - 使用
npx gem-book serve docs在本地预览构建的网站
GitHub Pages
使用 GitHub Actions 上传 dist/web,例如:
- run: npx gem-book build docs
- uses: actions/upload-pages-artifact@v3
with:
path: dist/web
- uses: actions/deploy-pages@v4Netlify / Vercel
构建命令设置为 npx gem-book build docs,发布(输出)目录设置为 dist/web,可以让静态资源长时间缓存,例如 vercel.json:
{
"headers": [
{
"source": "/static/(.*)",
"headers": [{ "key": "Cache-Control", "value": "public, max-age=31536000, immutable" }]
}
]
}