开张:为什么用静态站 + GitHub 评论
这台机子是 2 核 / 1.9 GB 内存 / 78 GB 磁盘的香港 VPS,跑动态博客(WordPress、Halo)也够,但我更想要没有数据库、没有 PHP、不会被评论刷爆的东西。
选型的三个硬约束
- 评论区不落本地:用 giscus,评论实际存在 GitHub Discussions 里,静态页只负责嵌一个 iframe。
- 发文章要快:Markdown 写完
tools/publish.sh,Hugo 静态生成 + Nginx 直接发文件,首字节基本在 10ms 级。 - 文件分发要多源:同一个下载页里,本地磁盘 / GitHub Release / Cloudflare R2 三个源的文件并列展示,每个都带 SHA-256。
日常怎么写文章
ssh [email protected]
cd /opt/site
hugo new posts/我的新文章.md
# 编辑内容
tools/publish.sh
publish.sh 会跑 hugo --minify 把站点生成到 /var/www/blog,Nginx 立刻生效,不用重启任何服务。
评论怎么开
到 giscus.app 授权 GitHub、选仓库和 Discussion 分类,把拿到的四个值写进 hugo.toml:
[params.giscus]
repo = "yourname/yourrepo"
repoId = "R_kgDOxxxxxxx"
category = "Announcements"
categoryId = "DIC_kwDOxxxxxxxx"
再 tools/publish.sh,每篇文章下面就会出现评论区。
评论区未配置。到 giscus.app
选好仓库 + Discussion 分类,抄下 4 个值,然后: