0

我在使用 Hugo v0.16 并创建主题时遇到问题。

基本上我定义了一个list.html带有{{ block }}条目的文件,以便稍后在我的分类中覆盖它

阅读此处的文档后,文件中似乎应该有一个好的入口点/themes/THEME/layouts/_default/taxonomy.html 。但是当我渲染它时index.html,它使用分类文件中的定义。我认为这是一个错误,但我只是想确定一下。

这是我的文件的基本内容:

_default/list.html

<h1>Foo {{ block "bar"}}{{ end }}</h1>

_default/taxonomy.html

 {{ define "bar" }}Bar{{ end }}

我所期待的:

索引.html

<h1>Foo </h1>

/taxonomy_plural/taxonomy_term/

<h1>Foo Bar</h1>

但是 index.html 看起来像 /taxonomy_plural/taxonomy_term/ 这不是我想要的

4

1 回答 1

0

我会回答我自己的问题,因为有人给了我一个解决方案

正如这里解释的https://discuss.gohugo.io/t/blocks-and-define-override-in-hugo-theme/3543,如果我使用 baseof*.html,我想做的事情是可能的。

所以这是最终的结构:

_default/baseof.html

 <h1>Foo {{ block "bar"}}{{ end }}</h1>

index.html为空且_default/taxonomy.html包含

{{ define "bar" }}Bar{{ end }}

它提供了我需要的东西

于 2016-06-22T15:10:58.973 回答