在hugo主题中阻止并定义覆盖

时间:2016-06-16 12:52:51

标签: hugo

使用Hugo v0.16并创建主题时,我遇到了一个问题。

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

阅读文档here之后,似乎一个好的入口点应该在index.html中 文件。但是当我渲染我的<h1>Foo {{ block "bar"}}{{ end }}</h1> 时,它使用了分类法文件中的define。我认为这是一个错误,但我只想确定。

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

_default / list.html

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

_default / taxonomy.html

<h1>Foo </h1>

我的期待:

的index.html

<h1>Foo Bar</h1>

/ taxonomy_plural / taxonomy_term /

{{1}}

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

1 个答案:

答案 0 :(得分:0)

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

正如https://discuss.gohugo.io/t/blocks-and-define-override-in-hugo-theme/3543所解释的那样,如果我使用* .html的基础,我想做的就是。

所以这是最终的结构:

_default / baseof.html

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

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

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

它提供了我需要的东西

相关问题