之前用 WordPress 嫌太重,Hexo 又觉得 node 依赖烦人,最后选了 Hugo。Go 写的单二进制,没有任何依赖,构建速度极快(几百篇文章秒级出)。
1. 安装 Hugo
Debian 12 直接 apt 装就行:
apt install -y hugo
hugo version
如果要最新版可以去 GitHub Release 下 deb 包。
2. 创建站点
hugo new site myblog
cd myblog
3. 安装主题
我选了 PaperMod,简洁干净:
git init
git submodule add https://github.com/adityatelange/hugo-PaperMod.git themes/PaperMod
在 hugo.toml 里加:
theme = "PaperMod"
4. 配置
baseURL = "https://example.com/"
languageCode = "zh-cn"
title = "我的博客"
[params]
author = "作者"
ShowReadingTime = true
ShowCodeCopyButtons = true
[[menu.main]]
identifier = "archives"
name = "归档"
url = "/archives/"
weight = 5
5. 写文章
hugo new posts/first-post.md
文章头部是 front matter:
---
title: "第一篇文章"
date: 2026-02-20T19:45:00+08:00
draft: false
categories: ["随笔"]
tags: ["test"]
---
正文内容...
6. 本地预览
hugo server -D # -D 包含 draft
浏览器打开 http://localhost:1313 就能看。
7. 构建
hugo --minify
生成的静态文件在 public/ 目录。
8. 部署到 VPS
我用的方案:本地构建,rsync 推送到 VPS 的 /var/www/html/:
hugo --minify
rsync -avz --delete public/ root@vps:/var/www/html/
也可以在 VPS 上直接放源码然后 cron 定时构建,或者用 GitHub Actions 推。
9. Nginx 配置
server {
listen 443 ssl http2;
server_name example.com;
root /var/www/html;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
10. 自动化
写个简单的部署脚本:
#!/bin/bash
cd ~/myblog
hugo --minify
rsync -avz --delete public/ root@vps:/var/www/html/
echo "Deployed at $(date)"
放到 ~/bin/deploy-blog.sh,chmod +x 后就能 deploy-blog.sh 一键部署了。
小结
Hugo 的优势是简单:单二进制、零依赖、构建快。配合 Nginx 静态托管,性能极好,VPS 几乎不吃资源。