Hugo 框架
Hugo 框架
介绍
- 主题:
使用
Hugo 安装
1
2
3
4
5
6
7
# 安装 golang
curl -sS https://webi.sh/golang | sh
# 安装 prebuilt Dart Sass(一般用不到)
# 安装 Hugo
curl -sS https://webi.sh/hugo | sh
快速搭建
- 快速搭建
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 初始化项目
hugo new site hugo-demo
cd hugo-demo
# 克隆主题
git clone [email protected]:biaslab/hugo-academic-group.git themes/hugo-academic-group
# 删除主题 git
rm -rf themes/hugo-academic-group/.git
cp -av themes/hugo-academic-group/exampleSite/* .
cp config.toml hugo.toml
# 本地预览
hugo server --watch
# 构建
hugo --minify
-
若 GitHub Pages 已绑定域名,可在
./static
目录中添加含域名的CNAME
文件 -
设置
hugo.toml
配置文件中的baseurl
的参数值为https://username.github.io/repo
- 目录结构
1
2
3
4
5
6
7
.
├── archetypes/
│ └── default.md
├── content/
├── hugo.toml # 配置文件
├── static/
└── themes/
部署
- GitHub Actions 示例
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
name: Hugo deploy
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
concurrency:
group: $-$
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: 'latest'
# extended: false
- name: Build
run: hugo --minify
- name: Deploy
uses: peaceiris/actions-gh-pages@v4
with:
github_token: $
publish_dir: ./public
This post is licensed under
CC BY 4.0
by the author.