GitHub Pages 在线电子书发布指南

发布地址

自动发布

main 分支推送提交后,GitHub Actions 会自动执行:

npm ci
  ↓
npm run diagrams:render
  ↓
npm run book:audit
  ↓
honkit build
  ↓
npm run site:prepare
  ↓
上传 _book/ 到 GitHub Pages

其中 site:prepare 会生成:

  • .nojekyll
  • robots.txt
  • sitemap.xml
  • 每个页面的 canonical 与 Open Graph 元数据。

日常发布流程

# 修改书稿后进行格式化
npm run book:format

# 检查章节、图片、代码块和链接
npm run book:audit

# 本地完整构建
npm run book:rebuild

# 提交并推送
git add .
git commit -m "docs: update book content"
git push

手动重新发布

进入 GitHub 仓库的 Actions → Deploy online book → Run workflow

GitHub Pages 设置

仓库应保持以下设置:

Settings
  → Pages
  → Build and deployment
  → Source: GitHub Actions

与个人博客共存

个人博客位于 arthaks/arthaks.github.io。为了防止 Chirpy 的 PWA Service Worker 缓存电子书路径,博客 _config.yml 应加入:

pwa:
  enabled: true
  cache:
    enabled: true
    deny_paths:
      - "/anthropic-engineering-guide"

博客可以通过 /books/ 书架页面链接到本书,不需要把书稿复制进博客仓库。

results matching ""

    No results matching ""