mirror of
https://github.com/zopiya/blog.git
synced 2025-11-02 19:56:47 +08:00
Update Hugo Config to Zopiya
This commit is contained in:
65
.github/workflows/deploy-blog.yml
vendored
65
.github/workflows/deploy-blog.yml
vendored
@@ -1,65 +0,0 @@
|
||||
name: Deploy Hugo Blog
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 6 * * *' # 每天早上 6 点(UTC)执行一次
|
||||
push:
|
||||
branches:
|
||||
- main # 当 main 分支有新提交时执行
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# 使用默认环境,并在最新的 Ubuntu 系统上运行
|
||||
environment: default
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# 1. 克隆当前博客仓库代码(包含完整历史记录)
|
||||
- name: 克隆当前博客仓库
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# 2. 安装 Hugo 静态站点生成器(extended 版本支持 Sass/SCSS 等扩展功能)
|
||||
- name: 安装 Hugo
|
||||
uses: peaceiris/actions-hugo@v3
|
||||
with:
|
||||
hugo-version: '0.145.0'
|
||||
extended: true
|
||||
|
||||
# 3. 克隆私有 wiki 仓库,作为博客内容的来源
|
||||
- name: 克隆私有 wiki 仓库
|
||||
run: |
|
||||
# 遇到错误立即退出,并确保管道中任一命令失败时退出
|
||||
set -eo pipefail
|
||||
# 清除旧的 wiki 临时目录,避免残留影响
|
||||
rm -rf /tmp/wiki
|
||||
# 使用 secrets 中存储的认证信息从私有仓库克隆 wiki 到 /tmp/wiki
|
||||
git clone https://${{ secrets.GITEA_REPO_READ }}@git.7wate.org/zhouzhongping/wiki.git /tmp/wiki
|
||||
|
||||
# 4. 将 wiki 中的博客内容拷贝到 Hugo 的 content/posts 目录中
|
||||
- name: 拷贝 wiki 内容到 content/posts
|
||||
run: |
|
||||
set -eo pipefail
|
||||
WIKI_BLOG_DIR="/tmp/wiki/Personal/Blog"
|
||||
TARGET_DIR="content/posts"
|
||||
if [ -d "$WIKI_BLOG_DIR" ]; then
|
||||
cp -r "$WIKI_BLOG_DIR"/* "$TARGET_DIR"/ || { echo "拷贝失败"; exit 1; }
|
||||
else
|
||||
echo "目录 $WIKI_BLOG_DIR 不存在,拷贝失败"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 5. 使用 Hugo 构建静态站点,并启用资源压缩优化
|
||||
- name: 构建 Hugo 静态站点
|
||||
run: |
|
||||
set -eo pipefail
|
||||
hugo --minify
|
||||
|
||||
# 6. 使用 gh-pages Action 将生成的静态站点部署到指定分支(此处为 html 分支)
|
||||
- name: 部署站点到 gh-pages 分支
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_branch: html
|
||||
publish_dir: ./public
|
||||
53
.github/workflows/deploy-pages.yml
vendored
Normal file
53
.github/workflows/deploy-pages.yml
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
name: Deploy Hugo to GitHub Pages
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 22 * * *"
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
concurrency:
|
||||
group: deploy-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
environment: production
|
||||
env:
|
||||
TZ: Asia/Shanghai
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Hugo
|
||||
uses: peaceiris/actions-hugo@v3
|
||||
with:
|
||||
hugo-version: '0.147.0'
|
||||
extended: true
|
||||
|
||||
- name: Clone private wiki repository
|
||||
run: |
|
||||
rm -rf /tmp/wiki && git clone "${{ secrets.GITEA_REPO_CLONE }}" /tmp/wiki
|
||||
if [ -d "/tmp/wiki/Personal/Blog" ]; then
|
||||
cp -r /tmp/wiki/Personal/Blog/* content/posts/ || exit 1
|
||||
else
|
||||
echo "Wiki content not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Build Hugo site
|
||||
run: hugo --minify
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
uses: peaceiris/actions-gh-pages@v4
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: ./public
|
||||
cname: zopiya.com
|
||||
user_name: 'github-actions[bot]'
|
||||
user_email: 'github-actions[bot]@users.noreply.github.com'
|
||||
@@ -23,7 +23,7 @@ layout: "about"
|
||||
|
||||
博客不设评论区,短期内也暂无开放计划。
|
||||
|
||||
但如果你有什么想说的,欢迎通过邮件联系:[zhouzhongping@7wate.com](mailto:zhouzhongping@7wate.com)
|
||||
但如果你有什么想说的,欢迎通过邮件联系:[i@zopiya.com](mailto:i@zopiya.com)
|
||||
|
||||
你也可以使用 Delta Chat 与我匿名通信:[点此扫码加好友](https://static.7wate.com/2025/03/26/bf7226c87704f.png)
|
||||
|
||||
|
||||
240
hugo.toml
240
hugo.toml
@@ -1,131 +1,181 @@
|
||||
# 网站基本信息
|
||||
baseURL = "https://blog.7wate.com/"
|
||||
languageCode = "zh-cn"
|
||||
title = "向阳而生"
|
||||
theme = "typo"
|
||||
defaultContentLanguage = "zh-cn"
|
||||
hasCJKLanguage = true
|
||||
enableEmoji = true
|
||||
canonifyURLs = true
|
||||
#────────────────────────────────────────────
|
||||
# 1. 全局基础设置
|
||||
#────────────────────────────────────────────
|
||||
# baseURL = "https://zopiya.com/"
|
||||
languageCode = "zh"
|
||||
title = "向阳而生"
|
||||
theme = "typo"
|
||||
defaultContentLanguage = "zh"
|
||||
hasCJKLanguage = true
|
||||
enableEmoji = true
|
||||
canonifyURLs = true
|
||||
timeout = "300s"
|
||||
enableRobotsTXT = true
|
||||
|
||||
# 构建性能
|
||||
timeout = "300s"
|
||||
#────────────────────────────────────────────
|
||||
# 2. 模块化(可选,推荐 Hugo Modules 管理主题)
|
||||
#────────────────────────────────────────────
|
||||
# [module]
|
||||
# [[module.imports]]
|
||||
# path = "github.com/7wate/typo"
|
||||
|
||||
# 永久链接结构
|
||||
#────────────────────────────────────────────
|
||||
# 3. URL 与国际化
|
||||
#────────────────────────────────────────────
|
||||
[permalinks]
|
||||
posts = ":slug/"
|
||||
|
||||
# 自定义分类标签
|
||||
# 如果未来要做多语言,这里可启用
|
||||
# enableMultilingual = true
|
||||
# [languages]
|
||||
# [languages.zh]
|
||||
# languageName = "中文"
|
||||
# weight = 1
|
||||
# [languages.en]
|
||||
# languageName = "English"
|
||||
# weight = 2
|
||||
|
||||
#────────────────────────────────────────────
|
||||
# 4. 自定义分类、标签、系列
|
||||
#────────────────────────────────────────────
|
||||
[taxonomies]
|
||||
tag = "tags"
|
||||
category = "categories"
|
||||
series = "series"
|
||||
tag = "tags"
|
||||
category = "categories"
|
||||
series = "series"
|
||||
|
||||
# 菜单设置
|
||||
[[params.menu]]
|
||||
name = "首页"
|
||||
url = "/"
|
||||
weight = 1
|
||||
#────────────────────────────────────────────
|
||||
# 5. 输出格式与输出控制
|
||||
#────────────────────────────────────────────
|
||||
[outputFormats]
|
||||
[outputFormats.RSS]
|
||||
mediaType = "application/rss+xml"
|
||||
baseName = "rss"
|
||||
isHTML = false
|
||||
isPlainText = false
|
||||
noUgly = true
|
||||
rel = "alternate"
|
||||
|
||||
[[params.menu]]
|
||||
name = "文辑"
|
||||
url = "/posts/"
|
||||
weight = 2
|
||||
[outputFormats.Feed]
|
||||
mediaType = "application/rss+xml"
|
||||
baseName = "feed"
|
||||
isHTML = false
|
||||
isPlainText = false
|
||||
noUgly = true
|
||||
rel = "alternate"
|
||||
|
||||
[[params.menu]]
|
||||
name = "片语"
|
||||
url = "https://memos.7wate.com/explore"
|
||||
newTab = true
|
||||
weight = 3
|
||||
[outputs]
|
||||
home = ["HTML", "RSS", "Feed", "SITEMAP", "ROBOTS"]
|
||||
|
||||
[[params.menu]]
|
||||
name = "关于"
|
||||
url = "/about/"
|
||||
newTab = true
|
||||
weight = 4
|
||||
|
||||
# Typo 主题参数
|
||||
#────────────────────────────────────────────
|
||||
# 6. 主题参数
|
||||
#────────────────────────────────────────────
|
||||
[params]
|
||||
description = "愿我们都能:执着于热爱,纯粹于当下。"
|
||||
theme = "auto"
|
||||
colorPalette = "base16-default"
|
||||
# 可选颜色:default, catpuccin, gruvebox, eink, base16-default, base16-eighties, base16-ocean, base16-mocha, base16-cupcake.
|
||||
description = "愿我们都能:执着于热爱,纯粹于当下。"
|
||||
theme = "auto"
|
||||
colorPalette = "base16-default"
|
||||
hideHeader = true
|
||||
readTime = true
|
||||
paginationSize = 10
|
||||
listSummaries = false
|
||||
# 若启用 listSummaries = true,需要指定 summaryLength
|
||||
# summaryLength = 70
|
||||
listDateFormat = "2006 Jan"
|
||||
homeDateFormat = "2 Jan"
|
||||
homeIntroTitle = "👋👋👋"
|
||||
homeIntroContent = """愿我们都能:执着于热爱,纯粹于当下。"""
|
||||
homeCollectionTitle = "文辑"
|
||||
homeCollection = "posts"
|
||||
|
||||
# 首页设置
|
||||
homeIntroTitle = "👋👋👋"
|
||||
homeIntroContent = """
|
||||
愿我们都能:执着于热爱,纯粹于当下。
|
||||
"""
|
||||
[params.breadcrumbs]
|
||||
enabled = true
|
||||
showCurrentPage = true
|
||||
home = "首页"
|
||||
|
||||
# 文辑设置
|
||||
homeCollectionTitle = "文辑"
|
||||
homeCollection = "posts"
|
||||
[params.umami]
|
||||
enable = true
|
||||
websiteId = "ce53db0e-af27-4703-ba19-d4792c8cff78"
|
||||
# 建议托管到 CDN 域名,或根目录以减少跨域请求
|
||||
jsLocation = "https://umami.7wate.com/script.js"
|
||||
|
||||
# 文章设置
|
||||
hideHeader = true
|
||||
readTime = true
|
||||
paginationSize = 7
|
||||
listSummaries = false
|
||||
listDateFormat = "2006 Jan"
|
||||
homeDateFormat = "2 Jan"
|
||||
#────────────────────────────────────────────
|
||||
# 7. 菜单与社交
|
||||
#────────────────────────────────────────────
|
||||
[[params.menu]]
|
||||
name = "首页"
|
||||
url = "/"
|
||||
weight = 1
|
||||
|
||||
# 面包屑导航
|
||||
[params.breadcrumbs]
|
||||
enabled = true
|
||||
showCurrentPage = true
|
||||
home = "首页"
|
||||
[[params.menu]]
|
||||
name = "文辑"
|
||||
url = "/posts/"
|
||||
weight = 2
|
||||
|
||||
# 社交链接
|
||||
[[params.social]]
|
||||
name = "github"
|
||||
url = "https://github.com/7wate"
|
||||
[[params.menu]]
|
||||
name = "片语"
|
||||
url = "https://memos.7wate.com/explore"
|
||||
newTab = true
|
||||
weight = 3
|
||||
|
||||
[[params.menu]]
|
||||
name = "关于"
|
||||
url = "/about/"
|
||||
newTab = true
|
||||
weight = 4
|
||||
|
||||
[[params.social]]
|
||||
name = "gmail"
|
||||
url = "mailto:zhouzhongping@7wate.com"
|
||||
name = "github"
|
||||
url = "https://github.com/zopiya"
|
||||
|
||||
[[params.social]]
|
||||
name = "rss"
|
||||
url = "https://blog.7wate.com/index.xml"
|
||||
name = "gmail"
|
||||
url = "mailto:i@zopiya.com"
|
||||
|
||||
# Markdown 与高亮设置
|
||||
[[params.social]]
|
||||
name = "rss"
|
||||
# 通常 RSS 放在 /rss.xml 而非 /index.xml
|
||||
url = "/rss.xml"
|
||||
|
||||
#────────────────────────────────────────────
|
||||
# 8. Markdown 与高亮
|
||||
#────────────────────────────────────────────
|
||||
[markup]
|
||||
[markup.highlight]
|
||||
style = "algol"
|
||||
|
||||
[markup.goldmark.renderer]
|
||||
unsafe = false
|
||||
unsafe = true # 生产环境建议设为 false
|
||||
|
||||
# 安全设置
|
||||
#────────────────────────────────────────────
|
||||
# 9. 安全与隐私
|
||||
#────────────────────────────────────────────
|
||||
[security]
|
||||
enableInlineShortcodes = true
|
||||
|
||||
# 站点地图(SEO)
|
||||
[sitemap]
|
||||
changefreq = "weekly"
|
||||
priority = 0.5
|
||||
filename = "sitemap.xml"
|
||||
|
||||
# RSS 订阅
|
||||
[services]
|
||||
[services.rss]
|
||||
limit = 7
|
||||
|
||||
# 网站分析
|
||||
[params.umami]
|
||||
enable = true
|
||||
websiteId = "ce53db0e-af27-4703-ba19-d4792c8cff78"
|
||||
jsLocation = "https://umami.7wate.com/script.js"
|
||||
|
||||
# 隐私与 GDPR
|
||||
[privacy]
|
||||
[privacy.googleAnalytics]
|
||||
anonymizeIP = true
|
||||
anonymizeIP = true
|
||||
respectDoNotTrack = true
|
||||
useSessionStorage = false
|
||||
disable = false
|
||||
disable = true # 如不使用 GA,建议删掉整个块
|
||||
|
||||
# 构建压缩设置
|
||||
#────────────────────────────────────────────
|
||||
# 10. 构建压缩与优化
|
||||
#────────────────────────────────────────────
|
||||
[minify]
|
||||
disableXML = true
|
||||
minifyOutput = true
|
||||
disableXML = false
|
||||
minifyOutput = true
|
||||
|
||||
#────────────────────────────────────────────
|
||||
# 11. 站点地图(SEO)
|
||||
#────────────────────────────────────────────
|
||||
[sitemap]
|
||||
changefreq = "weekly"
|
||||
priority = 0.5
|
||||
filename = "sitemap.xml"
|
||||
|
||||
#────────────────────────────────────────────
|
||||
# 12. RSS 服务
|
||||
#────────────────────────────────────────────
|
||||
[services]
|
||||
[services.rss]
|
||||
limit = 7 # -1 表示不限制条目数
|
||||
59
layouts/home.feed.xml
Normal file
59
layouts/home.feed.xml
Normal file
@@ -0,0 +1,59 @@
|
||||
{{- $authorEmail := "" }}
|
||||
{{- with site.Params.author }}
|
||||
{{- if reflect.IsMap . }}
|
||||
{{- with .email }}
|
||||
{{- $authorEmail = . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- $authorName := "" }}
|
||||
{{- with site.Params.author }}
|
||||
{{- if reflect.IsMap . }}
|
||||
{{- with .name }}
|
||||
{{- $authorName = . }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- $authorName = . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- $pctx := . }}
|
||||
{{- if .IsHome }}{{ $pctx = .Site }}{{ end }}
|
||||
{{- $pages := slice }}
|
||||
{{- if or $.IsHome $.IsSection }}
|
||||
{{- $pages = $pctx.RegularPages }}
|
||||
{{- else }}
|
||||
{{- $pages = $pctx.Pages }}
|
||||
{{- end }}
|
||||
{{- $limit := .Site.Config.Services.RSS.Limit }}
|
||||
{{- if ge $limit 1 }}
|
||||
{{- $pages = $pages | first $limit }}
|
||||
{{- end }}
|
||||
{{- printf "<?xml version= \"1.0\" encoding= \"utf-8\" standalone= \"yes\"?>" | safeHTML }}
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on
|
||||
{{ end }}{{ .Site.Title }}{{ end }}</title>
|
||||
<link>{{ .Permalink }}</link>
|
||||
<description>Recent
|
||||
content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{
|
||||
.Site.Title }}</description>
|
||||
<generator>Hugo</generator>
|
||||
<language>{{
|
||||
site.Language.LanguageCode }}</language>{{ with $authorEmail }} <managingEditor>{{.}}{{ with
|
||||
$authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }} <webMaster>{{
|
||||
. }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }} <copyright>{{
|
||||
. }}</copyright>{{ end }}{{ if not .Date.IsZero }} <lastBuildDate>{{ (index
|
||||
$pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{
|
||||
end }} {{- with .OutputFormats.Get "RSS" }} {{ printf "<atom:link href= %q rel= \"self\" type= %q />"
|
||||
.Permalink .MediaType | safeHTML }} {{- end }} {{- range $pages }} <item>
|
||||
<title>{{ .Title }}</title>
|
||||
<link>{{ .Permalink }}</link>
|
||||
<pubDate>{{ .PublishDate.Format
|
||||
"Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate> {{- with $authorEmail }}<author>{{
|
||||
. }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }} <guid>{{ .Permalink }}</guid>
|
||||
<description>{{
|
||||
.Summary | transform.XMLEscape | safeHTML }}</description>
|
||||
</item> {{- end }} </channel>
|
||||
</rss>
|
||||
59
layouts/home.rss.xml
Normal file
59
layouts/home.rss.xml
Normal file
@@ -0,0 +1,59 @@
|
||||
{{- $authorEmail := "" }}
|
||||
{{- with site.Params.author }}
|
||||
{{- if reflect.IsMap . }}
|
||||
{{- with .email }}
|
||||
{{- $authorEmail = . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- $authorName := "" }}
|
||||
{{- with site.Params.author }}
|
||||
{{- if reflect.IsMap . }}
|
||||
{{- with .name }}
|
||||
{{- $authorName = . }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- $authorName = . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- $pctx := . }}
|
||||
{{- if .IsHome }}{{ $pctx = .Site }}{{ end }}
|
||||
{{- $pages := slice }}
|
||||
{{- if or $.IsHome $.IsSection }}
|
||||
{{- $pages = $pctx.RegularPages }}
|
||||
{{- else }}
|
||||
{{- $pages = $pctx.Pages }}
|
||||
{{- end }}
|
||||
{{- $limit := .Site.Config.Services.RSS.Limit }}
|
||||
{{- if ge $limit 1 }}
|
||||
{{- $pages = $pages | first $limit }}
|
||||
{{- end }}
|
||||
{{- printf "<?xml version= \"1.0\" encoding= \"utf-8\" standalone= \"yes\"?>" | safeHTML }}
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on
|
||||
{{ end }}{{ .Site.Title }}{{ end }}</title>
|
||||
<link>{{ .Permalink }}</link>
|
||||
<description>Recent
|
||||
content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{
|
||||
.Site.Title }}</description>
|
||||
<generator>Hugo</generator>
|
||||
<language>{{
|
||||
site.Language.LanguageCode }}</language>{{ with $authorEmail }} <managingEditor>{{.}}{{ with
|
||||
$authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }} <webMaster>{{
|
||||
. }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }} <copyright>{{
|
||||
. }}</copyright>{{ end }}{{ if not .Date.IsZero }} <lastBuildDate>{{ (index
|
||||
$pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{
|
||||
end }} {{- with .OutputFormats.Get "RSS" }} {{ printf "<atom:link href= %q rel= \"self\" type= %q />"
|
||||
.Permalink .MediaType | safeHTML }} {{- end }} {{- range $pages }} <item>
|
||||
<title>{{ .Title }}</title>
|
||||
<link>{{ .Permalink }}</link>
|
||||
<pubDate>{{ .PublishDate.Format
|
||||
"Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate> {{- with $authorEmail }}<author>{{
|
||||
. }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }} <guid>{{ .Permalink }}</guid>
|
||||
<description>{{
|
||||
.Summary | transform.XMLEscape | safeHTML }}</description>
|
||||
</item> {{- end }} </channel>
|
||||
</rss>
|
||||
4
layouts/robots.txt
Normal file
4
layouts/robots.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
User-agent: *
|
||||
Allow: /
|
||||
RSS: {{ .Site.BaseURL }}index.xml
|
||||
Sitemap: {{ .Site.BaseURL }}sitemap.xml
|
||||
Reference in New Issue
Block a user