Hugo

Hugo。- Hugo [Installation | Hugo (gohugo.io)](https://gohugo.io/installation/)

快速使用

环境

  • Hugo

Installation | Hugo (gohugo.io)

  • Git

Git - Installing Git (git-scm.com)

创建项目

1
2
3
4
5
6
7
8
9
# 初始化项目(在当前的 test 文件夹下)
hugo new site ./test-site

# 添加主题
cd ./test-site
git clone https://github.com/theNewDynamic/gohugo-theme-ananke.git

# 配置,修改 hugo.toml 文件, 添加如下行(需要与主题文件夹名字一致)
theme = 'gohugo-theme-ananke'

运行

1
2
# 运行站点,检查是否正常启动
hugo server

访问站点url(url 会在命令行界面中打印出来,我本地是 http://localhost:54934/)

image-20231116180854090

添加内容

1
2
3
4
5
# 切换到项目根目录 test-site
cd "test-site路径"

# 添加博客
hugo new post/first-blog.md

编辑 first-blog.md,修改 draft: true 为 false,下文添加内容"测试博客",刷新浏览器

image-20231116180919129

发布

1
2
3
4
# 打包
hugo

# 发布:部署到服务器/PAAS 平台(Netlify、Vercel、train等)

结构梳理

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
test-site/
├── archetypes/
│   └── default.md	md 文件模板
├── assets/
├── content/		md 文件目录
│   └── post/		博客文件路径
├── data/
├── i18n/
├── layouts/		自定义网页模板
├── static/
├── themes/			主题
└── hugo.toml       站点配置
Licensed under CC BY-NC-SA 4.0
Gear(夕照)的博客。记录开发、生活,以及一些不足为道的思考……