hugo添加相关内容

Published on Aug. 22, 2023, 12:06 p.m.

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

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/

Tags: