Introduction
由于 WordPress 加载太慢, 而且 VPS 马上就要到期, 新的 VPS 不为 CN2 线路, 考虑到加载会更慢, 故将博客迁移至 Hugo, 此文刚开始为我个人在建站时的一些摸索, 加上一些之前的经验, 慢慢整理成了教程, 以飨后来者.
1. Hugo 建站
1.1. 安装 Hugo
先去 Hugo 官方网站
选择适合自己的安装方式, 本次选择去 GitHub 获取最新的 releases
.
下载完成后解压, 然后进入文件夹, 在上方路径键入 cmd 检查是否安装成功,输入: hugo version
, 若出现版本信息则表示安装成功. 将 hugo.exe
路径复制, 然后添加进环境变量的 path 变量.
1.2 新建站点
在 cmd 输入hugo new site blog
,就会在 blog 文件夹内出现如下目录
1.3. 下载主题
去 Hugo 主题官网
寻找自己喜欢的主题, 本文以 PaperMod 为例进行介绍. 下载 PaperMod 主题, 解压至 blog/themes
路径, 使用该主题的方法就是在站点文件夹下的配置文件里输入主题的名字:
1
theme: PaperMod # 主题名字,和themes文件夹下的一致
1.4..配置文件
站点配置文件推荐改成 .yaml
后缀的写法, 因为更适合阅读, 详细配置请看 Hugo 官方文档
,下面是我的配置:
注意这是 PaperMod 主题的配置方法,并不一定适用于其他主题.
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
baseURL : https://www.icey.one # 绑定的域名
languageCode : en-us # en-us
title : Icey One
theme : PaperMod # 主题名字,和themes文件夹下的一致
enableInlineShortcodes : true
enableEmoji : true # 允许使用 Emoji 表情,建议 true
enableRobotsTXT : true # 允许爬虫抓取到搜索引擎,建议 true
hasCJKLanguage : true # 自动检测是否包含 中文日文韩文 如果文章中使用了很多中文引号的话可以开启
buildDrafts : false
buildFuture : false
buildExpired : false
googleAnalytics : # 谷歌统计
# Copyright: Icey
paginate : 10 # 首页每页显示的文章数
minify :
disableXML : true
# minifyOutput: true
permalinks : # 访问博客时网址的显示形式
post : "/:slug/" #使用 slug 而不是 title 是为了使链接更短
# post: "/:year/:month/:day/:title/:filename/:slug"
defaultContentLanguage : en # 最顶部首先展示的语言页面
defaultContentLanguageInSubdir : true
languages :
en :
languageName : "English"
weight : 1
profileMode :
enabled : true
title : My wish is to see you again.
subtitle : 「私は──今の自分から、変わりたいと思ったからです」
imageUrl : "https://image.icey.one/i/2022/10/07/634044fd5525e.jpg"
#imageTitle: Icey
imageWidth : 150
imageHeight : 150
buttons :
- name : Drive
url : https://drive.icey.one
- name : Group
url : https://t.me/Iceyonechat
- name : Image
url : https://image.icey.one
#- name: RSS
# url: index.xml
menu :
main :
- identifier : search
name : Search
url : search
weight : 1
#- identifier: posts
# name: Post
# url: post
# weight: 2
- identifier : archives
name : Archives
url : archives
weight : 3
- identifier : tags
name : Tags
url : tags
weight : 15
- identifier : about
name : About
url : about
weight : 50
#- identifier: links
# name: Links
# url: links
# weight: 60
outputs :
home :
- HTML
- RSS
- JSON
# 这里的参数会被代码以 .Site.Params 的形式读取
params :
env : production # to enable google analytics, opengraph, twitter-cards and schema.
description : "My wish is to see you again, even across the world."
author : Icey
# author: ["Me", "You"] # multiple authors
defaultTheme: auto # defaultTheme : light or dark
disableThemeToggle : false
DateFormat : "2006-01-02"
ShowShareButtons : true
ShowReadingTime : true
# disableSpecialistPost: true
displayFullLangName : true
ShowPostNavLinks : true
ShowBreadCrumbs : true
ShowCodeCopyButtons : true
hideFooter : false # 隐藏页脚
ShowWordCounts : true
VisitCount : true
ShowLastMod : true #显示文章更新时间
ShowFullTextinRSS : true #RSS 全文
ShowToc : true # 显示目录
TocOpen : true # 自动展开目录
comments : true
socialIcons :
- name : Email
url : "mailto: im@icey.one"
- name : Matrix
url : "https://matrix.to/#/@motion_slow:matrix.org"
- name : Telegram
url : "https://t.me/Satomi_Akane_Bot"
- name : RSS
url : "index.xml"
# label: # 左上角图标
# text: "Icey's Blog"
# icon: "https://image.icey.one/i/2022/10/13/6347d8a16dd48.png"
# iconHeight: 35
analytics :
google :
SiteVerificationTag : ""
assets:#以下为各种尺寸标签页图标
favicon : "https://image.icey.one/i/2022/10/13/6347d8a16dd48.png"
favicon16x16 : "https://image.icey.one/i/2022/10/13/6347d8a16dd48.png"
favicon32x32 : "https://image.icey.one/i/2022/10/13/6347d8a16dd48.png"
apple_touch_icon : "https://image.icey.one/i/2022/10/13/6347d8a16dd48.png"
safari_pinned_tab : "https://image.icey.one/i/2022/10/13/6347d8a16dd48.png"
cover:#封面配置
hidden : false # hide everywhere but not in structured data
hiddenInList : false # hide on list pages and home
hiddenInSingle : false # hide on single page
fuseOpts : # 搜索配置
isCaseSensitive : false
shouldSort : true
location : 0
distance : 1000
threshold : 0.4
minMatchCharLength : 0
keys : [ "title" , "permalink" , "summary" ]
StartYear : 2021 # 底部开始年份
#FilingNo: 填写自己的备案号 # 底部备案号
#PublicSecurityIconLink: 填自己的公安图标链接 # 填自己的公安图标链接,可用绝对路径,相对路径如 img/beian.png
#PublicNetworkSecurity: 填自己的公网安备 # 底部公网安备号
#Reward: true #打赏是否开启
# 打赏微信图片地址,
# 可用绝对和相对地址,相对地址的图片需放在static/img下,
# 填写格式为img/wechat_pay.png
#WechatPay: img/wechat_pay.png
#Alipay: img/alipay.png #打赏支付宝图片地址
taxonomies :
category : categories
tag : tags
series : series
markup :
goldmark :
renderer :
unsafe : true # HUGO 默认转义 Markdown 文件中的 HTML 代码,如需开启的话
highlight :
# anchorLineNos: true
codeFences : true
guessSyntax : true
lineNos : true
noClasses : true
tabWidth : 4
style : monokai
# codeFences:代码围栏功能,这个功能一般都要设为 true 的,不然很难看,就是干巴巴的-代码文字,没有颜色。
# guessSyntax:猜测语法,这个功能建议设置为 true, 如果你没有设置要显示的语言则会自动匹配。
# hl_Lines:高亮的行号,一般这个不设置,因为每个代码块我们可能希望让高亮的地方不一样。
# lineNoStart:行号从编号几开始,一般从 1 开始。
# lineNos:是否显示行号,我比较喜欢显示,所以我设置的为 true.
# lineNumbersInTable:使用表来格式化行号和代码,而不是 标签。这个属性一般设置为 true.
# noClasses:使用 class 标签,而不是内嵌的内联样式
privacy :
vimeo :
disabled : false
simple : true
twitter :
disabled : false
enableDNT : true
simple : true
instagram :
disabled : false
simple : true
youtube :
disabled : false
privacyEnhanced : true
services :
instagram :
disableInlineCSS : true
twitter :
disableInlineCSS : true
1.5. 目录设置
注意: content 里每个文件夹内都要添加一个 ``_index.md` 文件, 该文件里面可以加 Front Matter 用来控制标题或其它的展示.
_index.md
里面填入如下内容:
1
2
3
title : "Language" #此处填入你想显示的名称
hidemeta : true #是否隐藏元信息, 如发布时间等, 建议打开
1.6. 生成预览
直接在终端输入 hugo server
即可通过 localhost:1313
预览博客内容. 输入 hugo
即可生成 public 文件夹, 将该文件夹托管至服务器或 GitHub 即可, 输入 hugo
的生成方式只会往 public 文件夹里添加内容, 但是不会删除外部已经不存在而 public 里面还存在的文件, 想要生成全新的文件夹请使用 hugo -F --cleanDestinationDir
.
1.7 生成新文章
我们首先打开 blog\archetypes\_default.md
修改原有内容如下 (此为 PaperMod 主题,其他主题请看相应文档)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
title : "{{ replace .Name " -" " " | title }}" #标题
slug : "{{ replace .Name " -" " " | title }}" #链接
date : {{ .Date }} #创建时间
lastmod : {{ .Date }} #更新时间
author : ["Icey" ] #作者
categories :
-
tags :
-
description : "" #描述
weight : # 输入1可以顶置文章,用来给文章展示排序,不填就默认按时间排序
draft : false # 是否为草稿
comments : true #是否展示评论
showToc : true # 显示目录
TocOpen : true # 自动展开目录
hidemeta : false # 是否隐藏文章的元信息,如发布日期、作者等
disableShare : true # 底部不显示分享栏
showbreadcrumbs : true #顶部显示当前路径
ShowsNavLinks : true #上一篇文章 || 下一篇文章
cover :
image : "" #图片路径, 支持图床链接
caption : "" #图片底部描述
alt : ""
relative : false
输入hugo new test.md
就会在 content/post
目录下生成名为 test.md
的文件, 所有文章都是放在 content 这个文件夹里 如果自己还定义了分类目录, 如在 content/posts
下有 math, tech 等文章分类,那么在用命令生成文章的时候, 如果要把文章生成到指定目录, 可以用命令: hugo new posts/tech/test.md
,这样就会把文章生成到 tech 目录下 生成的文章内部头部配置信息包括一些文章名称, 时间之类的信息, 这些信息即为我们刚才在 blog\archetypes\_default.md
配置的信息.
1.8. 添加搜索&归档
在 content 目录下新建 search.md
, 里面 yaml 填入如下内容
1
2
3
title : "Search" #显示标题
layout : search #指定为 search 类
placeholder : "Type keywords here..." #搜索框内文字
归档类似搜索, 头部 yaml 改为如下即可
1
2
3
4
title : "Archives"
layout : "archives"
url : "/archives/"
summary : archives
2. Hugo 常用命令
输入 hugo -h
可得到如下所有命令
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
hugo is the main command, used to build your Hugo site.
Hugo is a Fast and Flexible Static Site Generator
built with love by spf13 and friends in Go.
Complete documentation is available at https: //gohugo.io/.
Usage:
hugo [flags]
hugo [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
config Print the site configuration
convert Convert your content to different formats
deploy Deploy your site to a Cloud provider.
env Print Hugo version and environment info
gen A collection of several useful generators.
help Help about any command
import Import your site from others.
list Listing out various types of content
mod Various Hugo Modules helpers.
new Create new content for your site
server A high performance webserver
version Print the version number of Hugo
Flags:
- b, -- baseURL string hostname (and path) to the root, e.g. https: //spf13.com/
- D, -- buildDrafts include content marked as draft
- E, -- buildExpired include expired content
- F, -- buildFuture include content with publishdate in the future
-- cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/
-- cleanDestinationDir remove files from destination not found in static directories
-- clock string set the clock used by Hugo, e.g. -- clock 2021- 11- 06T22: 30: 00.00+ 09: 00
-- config string config file (default is path/config.yaml| json| toml)
-- configDir string config dir (default "config")
- c, -- contentDir string filesystem path to content directory
-- debug debug output
- d, -- destination string filesystem path to write files to
-- disableKinds strings disable different kind of pages (home, RSS etc.)
-- enableGitInfo add Git revision, date, author, and CODEOWNERS info to the pages
- e, -- environment string build environment
-- forceSyncStatic copy all files when static is changed.
-- gc enable to run some cleanup tasks (remove unused cache files) after the build
- h, -- help help for hugo
-- ignoreCache ignores the cache directory
-- ignoreVendorPaths string ignores any _vendor for module paths matching the given Glob pattern
- l, -- layoutDir string filesystem path to layout directory
-- log enable Logging
-- logFile string log File path (if set, logging enabled automatically)
-- minify minify any supported output format (HTML, XML etc.)
-- noChmod don't sync permission mode of files
-- noTimes don't sync modification time of files
-- panicOnWarning panic on first WARNING log
-- poll string set this to a poll interval, e.g -- poll 700ms, to use a poll based approach to watch for file system changes
-- printI18nWarnings print missing translations
-- printMemoryUsage print memory usage to screen at intervals
-- printPathWarnings print warnings on duplicate target paths etc.
-- printUnusedTemplates print warnings on unused templates.
-- quiet build in quiet mode
-- renderToMemory render to memory (only useful for benchmark testing)
- s, -- source string filesystem path to read files relative from
-- templateMetrics display metrics about template executions
-- templateMetricsHints calculate some improvement hints when combined with -- templateMetrics
- t, -- theme strings themes to use (located in / themes/THEMENAME/)
-- themesDir string filesystem path to themes directory
-- trace file write trace to file (not useful in general)
- v, -- verbose verbose output
-- verboseLog verbose logging
- w, -- watch watch filesystem for changes and recreate as needed
Use "hugo [command] -- help" for more information about a command.
其中常用命令有
1
2
3
4
5
6
7
# http://localhost:1313/ 生成预览
hugo server -D #只会添加新内容, 不会删除原有内容
# 重新生成 Public 目录, 覆盖原有文件
hugo -F --cleanDestinationDir
# 指定预览的主题, 必须在mywebsite文件夹下启动
# papermod是在themes文件夹下的主题名称
hugo -D server --theme=papermod
昨天发现 Hugo 自带的 RSS 只输出摘要, 而且还不只输出 article, 连 page 也会输出, 这不符合我对 RSS 的要求.
3.1 探索
自己动手, 丰衣足食, 在读了 Hugo 的文档以后, 发现 RSS 的目录为 themes 的 /layouts/_defualt/rss.xml
, 打开发现如下代码
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{{- $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" xmlns:content = "http://purl.org/rss/1.0/modules/content/" >
<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 >
{{- with $.Site.Params.images }}
<image >
<url >{{ index . 0 | absURL }}</url >
<link >{{ index . 0 | absURL }}</link >
</image >
{{- end }}
<generator >Hugo -- gohugo.io</generator >{{ with .Site.LanguageCode }}
<language >{{.}}</language >{{end}}{{ with .Site.Author.email }}
<managingEditor >{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor >{{end}}{{ with .Site.Author.email }}
<webMaster >{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster >{{end}}{{ with .Site.Copyright }}
<copyright >{{.}}</copyright >{{end}}{{ if not .Date.IsZero }}
<lastBuildDate >{{ .Date.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 }}
{{- if and (ne .Layout `search`) (ne .Layout `archives`) }}
<item >
<title >{{ .Title }}</title >
<link >{{ .Permalink }}</link >
<pubDate >{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate >
{{ with .Site.Author.email }}<author >{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author >{{end}}
<guid >{{ .Permalink }}</guid >
<description >{{ with .Description | html }}{{ . }}{{ else }}{{ .Summary | html }}{{ end -}}</description >
{{- if .Site.Params.ShowFullTextinRSS }}
<content:encoded >{{ (printf "<![CDATA[%s]]> " .Content) | safeHTML }}</content:encoded >
{{- end }}
</item >
{{- end }}
{{ end }}
</channel >
</rss >
注意到有一段代码为
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{{ range $pages }}
{{- if and (ne .Layout `search`) (ne .Layout `archives`) }}
<item >
<title >{{ .Title }}</title >
<link >{{ .Permalink }}</link >
<pubDate >{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate >
{{ with .Site.Author.email }}<author >{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author >{{end}}
<guid >{{ .Permalink }}</guid >
<description >{{ with .Description | html }}{{ . }}{{ else }}{{ .Summary | html }}{{ end -}}</description >
{{- if .Site.Params.ShowFullTextinRSS }}
<content:encoded >{{ (printf "<![CDATA[%s]]> " .Content) | safeHTML }}</content:encoded >
{{- end }}
</item >
{{- end }}
这段即为 RSS 全文输出的控制类, 可以发现其实 RSS 是有全文的, 只不过默认不输出, 我们将 {{ range $pages }}
改为 {{ range first 10 $pages }}
这里即为只输出最新的 10 篇 article.
接下来打开 config
文件, 在合适的地方加入 ShowFullTextinRSS: true
该命令即为输出 RSS 全文.
至此我们已完成 RSS 全文输出以及只输出最新几篇文章, 避免了 feed 过大的问题.
3.2 结束
或者直接复制下面代码即可.
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{{- $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" xmlns:content = "http://purl.org/rss/1.0/modules/content/" >
<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 >
{{- with $.Site.Params.images }}
<image >
<url >{{ index . 0 | absURL }}</url >
<link >{{ index . 0 | absURL }}</link >
</image >
{{- end }}
<generator >Hugo -- gohugo.io</generator >{{ with .Site.LanguageCode }}
<language >{{.}}</language >{{end}}{{ with .Site.Author.email }}
<managingEditor >{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor >{{end}}{{ with .Site.Author.email }}
<webMaster >{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster >{{end}}{{ with .Site.Copyright }}
<copyright >{{.}}</copyright >{{end}}{{ if not .Date.IsZero }}
<lastBuildDate >{{ .Date.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 first 5 $pages }}
{{- if and (ne .Layout `search`) (ne .Layout `archives`) }}
<item >
<title >{{ .Title }}</title >
<link >{{ .Permalink }}</link >
<pubDate >{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate >
{{ with .Site.Author.email }}<author >{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author >{{end}}
<guid >{{ .Permalink }}</guid >
<description >{{ with .Description | html }}{{ . }}{{ else }}{{ .Summary | html }}{{ end -}}</description >
{{- if .Site.Params.ShowFullTextinRSS }}
<content:encoded >{{ (printf "<![CDATA[%s]]> " .Content) | safeHTML }}</content:encoded >
{{- end }}
</item >
{{- end }}
{{ end }}
</channel >
</rss >
4. 页脚添加计数
我们这里选择 busuanzi
计数, 进入 blogthemes\PaperMod\layouts\partials\footer.html
找到如下代码 (应该在 footer 前几行)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{{- if not (.Param "hideFooter") }}
<footer class = "footer" >
{{- if .Site.Copyright }}
<span >{{ .Site.Copyright | markdownify }}</span >
{{- else }}
<span >© {{ .Site.Params.StartYear }}-{{ now.Year }} <a href = "{{ " " | absLangURL }}">{{ .Site.Title }}</a ></span >
{{- end }}
<span >
Powered by
<a href = "https://gohugo.io/" rel = "noopener noreferrer" target = "_blank" >Hugo</a > &
<a href = "https://git.io/hugopapermod" rel = "noopener" target = "_blank" >PaperMod</a >
</span >
</footer >
{{- end }}
我们在 </span>
后, </footer>
前加入 busuanzi 代码即可.
因为我不想出现太多汉字占位故, 改为如下代码, 将该代码直接复制替换上方原代码即可 (请勿直接将 footer 其他内容覆盖, 可能出现其他问题.)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{{- if not (.Param "hideFooter") }}
<footer class = "footer" >
{{- if .Site.Copyright }}
<span >{{ .Site.Copyright | markdownify }}</span >
{{- else }}
<span >© {{ .Site.Params.StartYear }}-{{ now.Year }} <a href = "{{ " " | absLangURL }}">{{ .Site.Title }}</a ></span >
{{- end }}
<span >
Powered by
<a href = "https://gohugo.io/" rel = "noopener noreferrer" target = "_blank" >Hugo</a > &
<a href = "https://git.io/hugopapermod" rel = "noopener" target = "_blank" >PaperMod</a >
</span >
<script async src = "//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script >
<span id = "busuanzi_container" >
<link rel = "stylesheet" href = "//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" >
<i class = "fa fa-user" ></i >
<span id = "busuanzi_value_site_uv" ></span >
<i class = "fa fa-eye" ></i >
<span id = "busuanzi_value_site_pv" ></span >
</span >
</footer >
{{- end }}
Reference
Hugo doc
Hugo RSS 全文输出
Hugo PaperMod wiki