这个博客是 Hugo + PaperMod,全文是 Markdown,躺在一个 Git 仓库里。
为什么是静态站点
三个理由,按重要性排:
- 没有数据库。没有数据库就没有注入、没有被拖库、没有「升级把数据搞坏」。整站的可变状态只有「服务器上那份可重新生成的 HTML」。
- Git 就是备份。所有文章的源码在仓库里,服务器挂了换一台,
git clone+hugo十五分钟恢复。 - 内存几乎为零。nginx 直接吐静态文件,常驻内存 20MB 上下。对比 WordPress 的 PHP-FPM + MySQL,省一个数量级。
写一篇新文章
# 在仓库根目录
.\scripts\new-post.ps1 -Name "我的新文章"
# 本地预览(含草稿)
.tools\bin\hugo.exe server -D
# 生成最终产物到 public/
.tools\bin\hugo.exe --minify --gc
文章在 content/posts/,草稿把 front matter 里的 draft: true 改成 false。
这个站点的结构
content/posts/ 文章(Markdown)
content/about.md 关于页
hugo.toml 站点配置
themes/PaperMod/ 主题(随仓库提交,不依赖网络)
deploy/ nginx 配置与部署脚本
public/ 构建产物(不进 Git)
下一步
- 域名解析 + HTTPS
- 备案下来后把备案号填进
hugo.toml的params.footer.text - 把
deploy/deploy.ps1接到 GitHub Actions,做到git push即上线