Files
Hugo/content/blog/setup-blog.md
T

59 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "从零搭建个人博客:Hugo + PaperMod 实践记录"
date: 2026-05-12T20:00:00+08:00
draft: false
description: "博客框架选型踩坑记录。为什么选 Hugo 而非 Hexo 或 WordPress,PaperMod 主题的安装曲折过程,以及 Snap Hugo 在 LXC 容器里的 cgroup 问题怎么绕过去。从零到上线,每一步都写清楚了。"
tags:
- Hugo
- 博客
- 教程
---
## 为什么选 Hugo
静态博客框架不少,选 Hugo 主要看中三点:
1. **快** — 编译以毫秒计,生成纯静态文件,部署无压力
2. **简单** — 一个二进制文件,无需 Node.js、PHP 等运行时依赖
3. **主题丰富** — PaperMod 主题简洁优雅,阅读体验好
## 环境
- **服务器**: 腾讯云 Lighthouse,北京地域
- **系统**: Ubuntu 24.04 LTS
- **域名**: 备案审核中
- **Hugo**: v0.161.1 (extended)
- **主题**: PaperMod v8
## 踩坑记录
### GitHub 下载慢
国内 VPS 下载 GitHub 上的文件速度感人,最终通过 GitHub API 的 `/zipball/master` 接口才成功拉下 PaperMod 主题:
```bash
curl -L -H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/adityatelange/hugo-PaperMod/zipball/master" \
-o papermod.zip
```
### Snap 里的 Hugo
系统里 apt 源的 Hugo 版本较旧(v0.123.7),snap 里有最新的 v0.161.1 但 snap 在 LXC 容器里有 cgroup 问题。解决方式是直接从 snap 挂载目录拷贝二进制:
```bash
cp /snap/hugo/current/bin/hugo /usr/local/bin/
```
## 最终效果
现在博客跑着 PaperMod 主题,支持:
- 明暗主题自动切换
- RSS 订阅
- 标签分类
- 代码高亮与复制
- 响应式布局
后续等备案通过后绑定域名,配上 HTTPS 正式证书就齐活了。