)
我正试图为hugo.io创建自己的主题。到目前为止一切都很好。我唯一的问题是,我不能让hugo呈现单个部分内容的自定义布局。
对于帖子,这是很好的:
问题:*对于教程,单个布局不调用“layout / tutorials /single.html”布局。相反,它使用“layout/_default/single.html”。
我尝试了以下几点:
可悲的是,这些都没有用。
我的内容设置:
content
|__ posts
|__ new_post.md
|__ tutorials
|__ new-tutorial.md我的布局设置(在主题文件夹中):
layouts
|__ _default
|__ list.html
|__ single.html
|__ posts
|__ list.html
|__ single.html
|__ tutorials
|__ list.html
|__ single.html
|__index.html我的一个教程内容(new-tutorial.md):
+++
title = "My new Tutorial"
date: 2019-10-04T14:10:46+02:00
draft: false
type: tutorial
layout: tutorial
+++
# Custom Content Headline没有雨果的错误信息。我希望hugo打开"http://localhost:1313/tutorials/new-tutorial/“页面,其布局位于文件”layout /tutorials/single.html“中。
发布于 2019-10-04 15:00:32
您不应该在新教程中指定type: tutorial和type:tutorial。
在默认情况下,Hugo将使用布局/教程/single.html作为教程一节,请参阅https://gohugo.io/templates/lookup-order/#examples-layout-lookup-for-regular-pages。
新教程. for的最终结果如下
+++
title = "My new Tutorial"
date: 2019-10-04T14:10:46+02:00
draft: false
+++
# Custom Content Headline发布于 2022-09-09 20:53:27
问题已经解决了,问题在类型的定义上。默认情况下,Hugo会给出教程文件夹中的元素,类型教程,如果将其更改为教程,则必须使用教程htmls创建一个子文件夹,这是新的类型。
layouts
|__ _default
|__ list.html
|__ single.html
|__ posts
|__ list.html
|__ single.html
|__ tutorials
|__ list.html
|__ single.html
|__ tutorial
|__ list.html
|__ single.html
|__index.html就像文件里说的

https://stackoverflow.com/questions/58237421
复制相似问题