Jekyll 构建与 GitHub 部署指南
Jekyll 构建与 GitHub 部署指南
来源类型: 操作指南
日期: 2026
标签: jekyll, github-pages, static-site, markdown, deployment, automation
核心内容
将 _posts 目录下的 Markdown 文件编译为 _site 中的 HTML 并提交到 GitHub 的完整操作步骤,涵盖 Jekyll 本地构建、gh-pages 分支管理、自动化脚本和常见问题排查。
关键结论
- 构建命令:
bundle exec jekyll build将 _posts/.md 解析为 _site/.html - 推荐部署方式:使用 gh-pages 独立分支存放编译产物,源码与产物分离
- 自动化:编写 deploy.sh 脚本实现构建 + 推送,或使用 GitHub Actions CI 自动构建
- 注意事项:.gitignore 中的 _site/ 行需注释/删除,推送被拒时用
git push -f强制覆盖 - 适用:Jekyll/Hugo/Hexo 等静态站点生成器,思路基本相同
参考链接
- Jekyll: https://jekyllrb.com/
- GitHub Pages: https://pages.github.com/