前言#
Hugo 是目前最快的静态网站生成器,用 Go 语言编写,构建速度在毫秒级别。这篇指南带你从零搭建一个博客。
安装 Hugo#
Windows#
winget install Hugo.Hugo.ExtendedmacOS#
brew install hugoLinux#
sudo apt install hugo创建站点#
hugo new site my-blog
cd my-blog添加主题#
以 PaperMod 为例:
git init
git submodule add https://github.com/adityatelange/hugo-PaperMod.git themes/PaperMod然后在 hugo.toml 中配置:
theme = "PaperMod"写文章#
hugo new post/my-article/index.md本地预览#
hugo server -D打开 http://localhost:1313 即可看到效果。
部署到 GitHub Pages#
- 在 GitHub 创建仓库
username.github.io - 构建站点:
hugo --minify - 将
public/推送到 GitHub
小结#
Hugo 的优势在于:
- 构建速度快
- 单二进制,无依赖
- 模板灵活
- 社区主题丰富
现在就开始你的博客之旅吧!