【发布时间】:2021-01-23 22:51:43
【问题描述】:
如何将 /posts 作为主页?
我应该重定向,更改 hugo 1config 中的 baseURL 还是更改 主题 2config?
脚注
1https://gohugo.io/getting-started/configuration/
2https://github.com/luizdepra/hugo-coder/wiki/Configurations
【问题讨论】:
标签: hugo
如何将 /posts 作为主页?
我应该重定向,更改 hugo 1config 中的 baseURL 还是更改 主题 2config?
1https://gohugo.io/getting-started/configuration/
2https://github.com/luizdepra/hugo-coder/wiki/Configurations
【问题讨论】:
标签: hugo
你可以修改 home.html 文件,因为 index.html 文件是嵌入的,而 index.html 中没有其他内容
https://github.com/luizdepra/hugo-coder/blob/master/layouts/partials/home.html
在 theme/layouts/partials/home.html 中的上述文件中进行更改,这些更改将在您保存文件后立即在网站上生效(如果您已经在运行 $ hugo server -D)
【讨论】:
list.html 文件呈现。可以在这里找到:github.com/luizdepra/hugo-coder/blob/master/layouts/posts/…
对我来说,将layouts/index.html 文件添加到我的主题很有帮助。以下是它的内容:
{{ define "main" }}
{{ $pag := .Paginate (where site.RegularPages "Type" "in" site.Params.mainSections ) 6 }}
<div class="archive-body">
{{ range $pag.Pages }}
{{ .Render "li" }}
{{ end }}
</div>
{{ partial "pagination" . }}
{{ end }}
"li" 是一个部分 HTML 模板,它为我呈现一个页面。
然后我必须在我的config.toml 中指定mainSections。由于我的内容位于content/post目录内,所以这里是配置。
[params]
mainSections = ["post"]
由于这是一个列表,您应该可以添加多个部分。例如,如果您的内容在content/post 和content/articles 之间传播,等等。不过我没试过。
【讨论】: