Default / 默认 · 8月 31, 2021

hugo添加相关内容

内容纲要

修改主题中的如下文件,如果没有可以创建。

layouts / partials / related.html

{{ $related := .Site.RegularPages.Related . \| first 5 }}
{{ with $related }}
<h3>See Also</h3>
<ul>
    \{\{ range . \}\}
    <li><a href="\{\{ .RelPermalink \}\}">{{ .Title }}</a></li>
    {{ end }}
</ul>
{{ end }}

<p>config.toml文件中添加如下内容</p>
<p>“`
[related]
includeNewer = false
threshold = 80
toLower = false

[[related.indices]]
name = “keywords”
weight = 100

[[related.indices]]
name = “tags”
weight = 90

[[related.indices]]
name = “date”
weight = 10
“`

发布文章时候不要忘记在头部添加tags内容,还有可以添加keywords.
tags:
- niubi
- haha

文档地址
https://gohugo.io/content-management/related/

%d 博主赞过: