用 Hugo 搭建静态博客(含搜索与暗色)
目录
为什么选 Hugo
内容即 Markdown,构建出纯静态 HTML,部署到 Cloudflare Pages 几乎零运维。
最小步骤
- 初始化:
hugo new site mysite,把布局写在layouts/。 - 组织内容:
content/books、content/tools、content/dao、content/life各建_index.md。 - 搜索:构建后跑
npx pagefind --site public,页面引/pagefind/pagefind-ui.js。 - 暗色:CSS 用
[data-theme]变量,JS 切换并写入localStorage。
行动清单
- 每次写完文章,本地
hugo server预览。 - 推到 Git,Cloudflare Pages 自动构建上线。