把 Hugo 博客部署到 Cloudflare Pages(GitHub 自动更新版)

这篇文章记录我把本地(或 VPS 上)的 Hugo 静态博客迁移到 Cloudflare Pages 的全过程,并实现: GitHub 仓库驱动发布:每次 git push 都会触发自动构建与部署 pages.dev 域名直接上线(也支持后续绑定自定义域名) 我的目标很简单:以后只管写文章 + push,其它交给 Cloudflare。 0. 你需要准备什么 一个 Hugo 站点(例如本地 myblog/) 一个 GitHub 仓库(用于存放站点源码) 一个 Cloudflare 账号 1. 把 Hugo 站点推到 GitHub 进入 Hugo 目录: cd ~/clawd/myblog 初始化仓库并写 .gitignore(不要把构建产物提交上去): git init cat > .gitignore <<'EOF' public/ resources/ .hugo_build.lock .DS_Store EOF 提交代码: git add . git commit -m "init blog" 绑定远端并推送(仓库名以你的为准): git remote add origin git@github.com:greatcorrectandglory/clawtest.git git branch -M main git push -u origin main 如果你还没配置 SSH key,需要先把服务器的 ~/.ssh/id_ed25519.pub 添加到 GitHub 的 SSH keys。 ...

February 3, 2026 · 2 min