【发布时间】:2020-02-02 20:27:35
【问题描述】:
)
我正在尝试为 hugo.io 创建自己的主题。到目前为止,一切正常。我唯一的问题是,我无法让 hugo 为单节内容呈现自定义布局。
对于帖子,这很好用:
- index.html 被正确调用
- “布局/帖子”中的 single.html 被正确调用
- 对于教程,列表布局可以正常工作
- 所有文件和列表的永久链接都能正常工作
问题: * 对于教程,单一布局不调用“layouts/tutorials/single.html”布局。相反,它使用“layouts/_default/single.html”
我尝试了以下方法:
- 将 type="tutorial" 前言设置添加到所有教程 .md 文件中
- 为所有教程 .md 文件添加 layout="tutorial" 前言设置
- 在“layouts/_default”文件夹中添加一个“tutorial.html”文件(也尝试将其命名为“tutorials.html”)
- 在“layouts”文件夹中添加一个“tutorial.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/”,其布局位于文件“layouts/tutorials/single.html”中
【问题讨论】:
-
最后我尝试重新设置整个项目。在我创建了一个新站点/项目并创建了一个新主题并完成了所有内容和主题文件的整个复制和粘贴之后......一切都再次正常。所以我认为问题不在于讨论的文件中?
-
你有没有想过这个问题?我面临着类似的问题,正在寻找线索。
-
@JensZalzala - 你解决了吗?我有同样的问题..
标签: hugo