I built this blog with Hugo and the PaperMod theme. The source lives in GitHub, GitHub Actions builds and deploys the site, and GitHub Pages serves the resulting files. Cloudflare manages the DNS records for my domain. This post walks through the setup, from the first local preview to a working site at https://zhiq.dev/. It also covers three issues I encountered along the way: a missing draft post, a custom domain validation error, and a stylesheet returning HTTP 404. ...
用 Hugo、GitHub Pages 和 Cloudflare 搭建个人博客
我用 Hugo 和 PaperMod 搭建了这个博客,将源码放在 GitHub,通过 GitHub Actions 自动构建并发布到 GitHub Pages,最后用 Cloudflare 管理域名解析。 这篇文章记录从本地预览到通过 https://zhiq.dev/ 访问的完整流程,也整理了搭建时遇到的三个问题:草稿在线上不显示、域名校验报错,以及切换域名后 CSS 返回 404。 本文的示例仓库是 zhiq26/blog,域名是 zhiq.dev。复用时请替换为自己的用户名、仓库和域名。示例命令使用 Bash;Windows 用户可以使用 Git Bash。 1. 先弄清楚各部分负责什么 组件 作用 Hugo 将 Markdown 和主题编译成静态网页 PaperMod 提供博客的页面样式和布局 GitHub 仓库 保存文章、配置、主题引用和工作流 GitHub Actions 在推送源码后执行构建和部署 GitHub Pages 托管构建生成的静态文件 Cloudflare DNS 将自己的域名解析到 GitHub Pages 这里使用的是 GitHub Pages 托管网站,Cloudflare 负责 DNS。并没有使用 Cloudflare Pages。 我按三个阶段验证:先让本地页面正常,再让 GitHub Pages 默认地址正常,最后绑定自定义域名。每次只增加一层配置,排错比较容易。 2. 创建 Hugo 项目并添加主题 先安装 Git 和 Hugo,并检查命令是否可用: ...