安装静态网站生成器hugo-extended
官方教程
https://gohugo.io/getting-started/installing/
创建或使用守望者仓库watcher_dnasdw
https://github.com/new
https://github.com/dnasdw/watcher_dnasdw
创建部署仓库dnasdw.github.io
https://github.com/new
https://github.com/dnasdw/dnasdw.github.io
https://github.com/new
https://github.com/dnasdw/comments_dnasdw
创建源文件仓库pages_dnasdw
https://github.com/new
https://github.com/dnasdw/pages_dnasdw
克隆到本地并新建站点
1
2
3
|
git clone --recursive https://github.com/dnasdw/pages_dnasdw.git
hugo new site pages_dnasdw --force
cd pages_dnasdw
|
创建.gitignore
内容来自https://github.com/github/gitignore/blob/main/community/Golang/Hugo.gitignore
1
2
3
4
5
6
7
8
9
10
11
12
13
|
# Generated files by hugo
/public/
/resources/_gen/
/assets/jsconfig.json
hugo_stats.json
# Executable may be added to repository
hugo.exe
hugo.darwin
hugo.linux
# Temporary lock file while building
/.hugo_build.lock
|
添加主题
1
|
git submodule add https://github.com/dnasdw/DoIt.git themes/DoIt
|
修改config.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
|
baseURL = "https://dnasdw.github.io/"
defaultContentLanguage = "zh-cn"
theme = "DoIt"
title = "巨好玩"
[languages]
[languages.zh-cn]
languageCode = "zh-CN"
hasCJKLanguage = true
[params]
version = "0.2.X"
|
提交推送
1
2
3
|
git add *
git commit -m setup
git push origin master
|
创建MY_GITHUB_TOKEN
查看是否已有token
https://github.com/settings/tokens
如果没有则新建token
https://github.com/settings/tokens/new
配置参考
1
2
3
4
|
Note: actions-gh-pages
Expiration: No expiration
Select scopes:
[v] repo
|
把MY_GITHUB_TOKEN配置到守望者仓库中
查看是否已配置token
https://github.com/dnasdw/watcher_dnasdw/settings/secrets/actions
如果没有则配置token
https://github.com/dnasdw/watcher_dnasdw/settings/secrets/actions/new
配置参考
配置守望者
克隆到本地
1
2
3
|
git clone --recursive https://github.com/dnasdw/watcher_dnasdw.git
cd watcher_dnasdw
git submodule add https://github.com/dnasdw/pages_dnasdw.git pages_dnasdw
|
创建github actions配置.github/workflows/dnasdw-gh-pages.yml
配置参考
https://github.com/dnasdw/public_reference/blob/master/YAML/.github/workflows/dnasdw-gh-pages.yml
提交推送
1
2
3
|
git add *
git commit -m "setup pages"
git push origin master
|
配置中转worker
教程
https://github.com/dnasdw/workflow_dispatch-worker
配置参考
1
2
|
GITHUB_WEBHOOK_SECRET: 2008*
Payload URL: https://webhook_workflow_dispatch-worker.dnasdw.workers.dev/api/github/repos/dnasdw/watcher_dnasdw/actions/workflows/dnasdw-gh-pages.yml/dispatches
|
github pages地址
配置地址
https://github.com/dnasdw/dnasdw.github.io/settings/pages
页面地址
https://dnasdw.github.io/
安装评论系统
https://utteranc.es/
应用地址
https://github.com/apps/utterances
配置权限
1
|
Only select repositories: dnasdw/comments_dnasdw
|
更新config
配置参考
https://github.com/dnasdw/public_reference/blob/master/TOML/pages_dnasdw/config.toml
头像文件
创建assets/images/dnasdw256.png
, 并将config中的头像路径改为/images/dnasdw256.png
.
网站图标
准备一个512x512的图标, 比如去https://www.flaticon.com/搜索一个合适的.
去https://realfavicongenerator.net/上传图标, 下载得到图标配置包, 解压到static目录.
补充缺失的中文译文
创建i18n/zh-CN.toml
1
2
3
4
5
6
|
# Translations for Simplified Chinese
# 简体中文的翻译
# https://gohugo.io/content-management/multilingual/#translation-of-strings
[authors]
other = "作者"
|
作者配置
创建data/authors/dnasdw.toml
1
2
|
name = "dnasdw"
link = "https://github.com/dnasdw"
|
之后就可以在文章的Front Matter中使用authors: [dnasdw]
.
配置PWA
创建content/offline/index.md
1
2
3
4
5
|
---
title: "离线"
---
> 你没有连接至互联网, 只有缓存的页面可用.
|
修改static/site.webmanifest
, 添加start_url
, 并填写name
/short_name
/start_url
.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
{
"name": "巨好玩",
"short_name": "巨好玩",
"start_url": "/",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
|