Hugo 主题
Cactus
一个简洁、响应式的个人博客 Hugo 主题。Fork 自 @probberechts 创建的 Hexo 主题 cactus。
Cactus
一个用于个人博客的 Hugo 主题。Fork 自 @probberechts 创建的 Hexo 主题 cactus。
在 github pages 上查看实时演示。
一些工作仍在进行中。请参阅下面的 TODO。
安装
- 将 cactus 克隆到您的 Hugo 站点的
themes
文件夹。
git clone https://github.com/monkeyWzr/hugo-theme-cactus.git themes/cactus
- 在您的站点配置中将主题更改为 cactus
# config.toml
theme = "cactus"
- 配置您的站点。请参阅 [配置] 或完整的配置示例
- 测试您的站点
hugo server
- 以您喜欢的方式发布您的站点。请参阅 Hugo 的文档:托管和部署
配置
颜色主题
[params]
colortheme = "white" # dark, light, white, or classic
自定义 CSS
[params]
css = ["css/custom.css"]
您可以添加多个自定义样式表,这些样式表将在主题主 CSS 之后加载。例如,上面的一行将加载位于 /static/css/custom.css
的 CSS 文件。
导航
# Main menu which appears below site header.
[[menu.main]]
name = "Home"
url = "/"
weight = 1
[[menu.main]]
name = "All posts"
url = "/posts"
weight = 2
[[menu.main]]
name = "Tags"
url = "/tags"
weight = 3
[[menu.main]]
name = "About"
url = "/about"
weight = 4
主页设置
- description:描述将显示在主页上。描述字符串支持 Markdown 语法。
[params]
description = "Hugo is a general-purpose website framework. Technically speaking, Hugo is a static site generator. Unlike systems that dynamically build a page with each visitor request, Hugo builds pages when you create or update your content. Since websites are viewed far more often than they are edited, Hugo is designed to provide an optimal viewing experience for your website’s end users and an ideal writing experience for website authors."
- 设置您的主部分(用作主页上“文章”标题的链接)
[params]
mainSection = "posts"
- 将默认的主部分标题从“文章”更改为其他内容
[params]
mainSectionTitle = "Blog"
- 仅显示 5 篇最新文章(默认)
[params]
showAllPostsOnHomePage = false
postsOnHomePage = 5
- 显示所有文章
[params]
showAllPostsOnHomePage = true
postsOnHomePage = 5 # this option will be ignored
- 显示标签概览(默认)或不显示
[params]
tagsOverview = true
- 在博客文章中内联显示目录,而不是作为导航菜单的一部分
[params]
tocInline = true
- 显示项目列表(默认)或不显示。
[params]
showProjectsList = true
projectsUrl = "https://github.com/monkeyWzr"
如果未检测到数据文件,则不会显示项目部分。请参阅下面的项目列表。
项目列表
创建您的项目数据文件 data/projects.yaml|toml|json
。Hugo 支持 yaml、toml 和 json 格式。对于以前的 Hexo cactus 用户:请将您的 json 数组分配给一个 list
键。
例如,data/projects.json
{
"list": [
{
"name":"Hexo",
"url":"https://hexo.node.org.cn/",
"desc":"A fast, simple & powerful blog framework"
},
{
"name":"Font Awesome",
"url":"http://fontawesome.io/",
"desc":"The iconic font and CSS toolkit"
}
]
}
社交媒体链接
[[params.social]]
name = "github"
link = "https://github.com/monkeyWzr"
[[params.social]]
name = "email"
link = "monkeywzr@gmail.com" # no need for "mailto:" at the start
[[params.social]]
name = "linkedin"
link = "https://www.linkedin.com/in/monkeywzr/"
name
键需要 Font Awesome 图标的名称。
版权
将您的版权分配给 .Site.Copyright
。Cactus 将在头部附加当前年份。
TODO:可自定义的版权年份
copyright = "Zeran Wu" # cactus theme will use site title if copyright is not set
评论
评论默认禁用。在您的 .Site.Params
中启用评论。
[params]
[params.comments]
enabled = true
# engine = "disqus" # in progress
您还可以为每篇文章启用/禁用评论。在您的文章的 front matter 中,添加
comments: true
当 front matter 中存在 comments
选项时,将忽略站点配置。
默认引擎是 disqus。目前,Cactus 仅支持 disqus。 我会尽快添加更多选项。请参阅评论替代方案
在使用 disqus 之前,您需要注册并获取您的 disqus 短名称。在 .Site.disqusShortname
中分配您的短名称,否则 cactus 将默认使用 .Site.Title
。
disqusShortname = "wzr" # cactus will use site title if not set
高亮
使用 Hugo 的内置语法高亮显示。
默认配置
[markup]
[markup.highlight]
codeFences = true
guessSyntax = false
hl_Lines = ""
lineNoStart = 1
lineNos = false
lineNumbersInTable = true
noClasses = true
style = "monokai"
tabWidth = 4
分析
Cactus 使用 Hugo 的内置分析模板。有关详细信息,请查看 Hugo 的文档。
在您的站点配置中设置您的跟踪 ID。
googleAnalytics = "UA-XXXXXXXX-XX" # or G-XXXXXXXX if you are using Google Analytics v4 (gtag.js)
如果您正在使用 Google Analytics v3 (analytics.js),您可以通过将 params.googleAnalyticsAsync
设置为 true
来切换到异步跟踪。
[params]
googleAnalyticsAsync = true # not required
RSS
默认情况下不会生成 RSS 源。您可以在站点配置中启用它
[params]
rss = true
假设您的 baseURL
设置为 https://example.com/
,则 RSS 链接将是 https://example.com/index.xml
另请查看配置 RSS
Mathjax
Cactus 支持 mathjax。只需在您的站点配置中添加 mathjax
选项即可
[params]
mathjax = true # not required
您还可以为每篇文章启用/禁用 mathjax。在您的文章的 front matter 中,添加
mathjax: true # or false
当 front matter 中存在 mathjax
选项时,将忽略站点配置。
存档
可以禁用文章归档上的分页,以按时间顺序显示所有文章
[params]
showAllPostsArchive = true # or false (default)
待办事项
- 更多评论引擎
- RSS
- 国际化 (I18n)
- 分析
- 本地搜索
- 目录模板
- 可自定义的版权年份
- 图库
- 暴露 MathJax 配置
许可证
MIT