原先的hugo和主题都装了很久了,今天进行了升级和并对原先乱七八糟的设定进行了重新修改。升级比较简单下载hugo.exe覆盖即可,新增站点是配置文件名发生了变化:config.toml→hugo.toml。
1. hugo配置 #
baseURL = "https://tndyx.gitee.io/"
languageCode = "zh"
#languageCode = "zh-CN"
title = "鸵鸟的邮箱"
theme = "book"
## 保持分类的原始名字(false会做转小写处理)
preserveTaxonomyNames = true
## 是否禁止URL Path转小写
disablePathToLower = true
## 自动检测是否包含中文/日文/韩文,建议设置为true
hasCJKLanguage = true
## 摘要长度
summaryLength = 140
## 分页
paginate = 10
paginatePath = "page"
[author]
name = "鸵鸟的邮箱"
[params]
author = "鸵鸟的邮箱"
subtitle = "tndyx"
keywords = "tndyx"
description = "tndyx"
busuanzi = true
# 是否开启本地搜索
BookSection = 'docs'
BookSearch = true
localSearch = true
# Set source repository location.
# Used for 'Last Modified' and 'Edit this page' links.
BookRepo = 'https://tndyx.gitee.io'
# (Optional, default 'commit') Specifies commit portion of the link to the page's last modified
# commit hash for 'doc' page type.
# Requires 'BookRepo' param.
# Value used to construct a URL consisting of BookRepo/BookCommitPath/<commit-hash>
# Github uses 'commit', Bitbucket uses 'commits'
BookCommitPath = 'commit'
# 评论??
#BookComments = true
# Configure the date format used on the pages
# - In git information
# - In blog posts
BookDateFormat = 'January 2, 2006'
[markup]
[markup.tableOfContents] #文章导航设置
endLevel = 6 #6级标题以后不建立索引
ordered = false #是否采用有序列表
startLevel = 1 #1级标题开始建立索引
[markup.goldmark.renderer] # Needed for mermaid/katex shortcodes
unsafe = true
2. 修改hugo-book文件增加日期和标题 #
book主题原先设计的是书的章节构架,没有日期和标题,适当修改模板,在文章内容上增加日期和标题,同时删除因增加标题和日期造成博客的重复的标题。
# 修改的文件夹路径为\themes\book\layouts\partials\docs\inject\content-before.html
<h1>
<a href="{{ .RelPermalink }}">{{ partial "docs/title.html" . }}</a>
</h1>
{{ partial "docs/post-meta" . }}
因为是在所有的 内容前面增加的标题和日期,所以博客本身就有的就会重复要进行删除。
# 修改的文件夹路径为\themes\book\layouts\posts\single.html
<h1>
<a href="{{ .RelPermalink }}">{{ partial "docs/title.html" . }}</a>
</h1>
{{ partial "docs/post-meta" . }}
3. 页面文档属性的设定 #
---
# 如果要在配置部分之外渲染页面,或者渲染“docs”以外的部分,请将 type 设置为 'docs'
# type: 'docs'
# 修改显示的分层标题,原文件夹不变,若不启用,显示文件名
# title: python
# 设置页面权重以重新排列文件树菜单中的项目(如果未设置 BookMenuBundle)
weight: 10
# (可选)设置为 'true' 以在文件树菜单中将页面标记为平面部分(如果未设置 BookMenuBundle)
bookFlatSection: false
# (可选) 设置为隐藏该级别的嵌套部分或页面。仅适用于文件树菜单模式
bookCollapseSection: true
# (可选) 设置 true 以隐藏侧边菜单中的页面或部分(如果未设置 BookMenuBundle)
bookHidden: false
# (可选)设置 'false' 以隐藏页面中的 ToC
bookToC: true
# (可选)如果已为网站启用了 BookComments,则可以对特定页面禁用它。
bookComments: true
# (可选)设置为“false”以从搜索索引中排除页面。
bookSearchExclude: true
# (可选) 在菜单中为此页面设置显式 href 属性(如果未设置 BookMenuBundle)
bookHref: ''
---
4. 增加页脚内容 #
2024-03-17新增: 在footer.html中增加版权等内容和访问统计,统计是使用不蒜子的统计。 路径:
/themes/book/layouts/partials/docs/footer.html
新增一个div片段,可以自定义style:
<div>
<footer>
<style>
.full-width-line {
width: 100%; /* 横线横贯整个页面 */
border: 0; /* 移除默认边框 */
height: 1px; /* 设置线的高度 */
background: #000; /* 设置线的颜色 */
margin: auto; /* 上下自动间距居中 */
}
</style>
<hr class="full-width-line">
<p>© {{ now.Format "2006" }} Powered By Hugo,模板:Hugo-book . Contact: <a href="mailto:tndyx@hotmail.com">tndyx@hotmail.com</a></p>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<span id="busuanzi_container_site_uv">本站总访问量<span id="busuanzi_value_site_uv"></span>次</span>
<span id="busuanzi_container_page_pv">本文总阅读量<span id="busuanzi_value_page_pv"></span>次</span>
<!--<nav>
<ul>
<li><a href="/privacy-policy">Privacy Policy</a></li>
<li><a href="/terms-of-service">Terms of Service</a></li>
</ul>
</nav> -->
<!-- Add more footer content here -->
</footer>
</div>