一步步记录这次网站的部署过程#
1. 安装 Hugo#
macOS 用 Homebrew 安装:
brew install hugo
hugo version2. 创建站点#
hugo new site 项目目录名
cd 项目目录名
git init
git submodule add https://github.com/alex-shpak/hugo-book themes/hugo-book3. 配置主题#
编辑 hugo.toml,填入:
baseURL = 'http://localhost:1313/'
title = 'Tolaria Note'
theme = 'hugo-book'
[markup.goldmark.renderer]
unsafe = true
[params]
BookTheme = 'auto'
BookSection = '*'
BookSearch = true4. 写内容#
在 content/ 下按分类建目录,每个目录放 _index.md 和文章 .md 文件。
每篇文章必须以前置元数据开头:
---
title: "文章标题"
date: 2026-06-03
categories: ["分类"]
---
正文...5. 本地预览#
hugo server --buildDrafts浏览器打开 http://localhost:1313 即可查看。
6. 推送到 GitHub#
git add -A && git commit -m "说明" && git push7. Cloudflare Pages 部署#
- 登录 Cloudflare Dashboard
- Workers & Pages → 创建 → Pages → 连接到 Git
- 选择仓库,框架预设选 Hugo
- 高级设置 → 环境变量 → 添加
HUGO_VERSION=0.162.1 - 点击保存并部署
8. 自动更新#
以后每次写完文章,只需:
git add -A && git commit -m "新文章" && git pushCloudflare 检测到推送后会自动重新构建部署,几分钟内生效。