)
I'm trying to create my own theme for hugo.io. So far, everything works fine. My only problem is, that I can't get hugo to render the custom layouts for single section content.
For posts this works fine:
The problem: * For tutorials, the single layout doesn't call the "layouts/tutorials/single.html" layout. Instead it uses "layouts/_default/single.html"
I tried the following:
sadly, none of this works
My setup of content:
content
|__ posts
|__ new_post.md
|__ tutorials
|__ new-tutorial.md
My setup of layouts (inside my theme folder):
layouts
|__ _default
|__ list.html
|__ single.html
|__ posts
|__ list.html
|__ single.html
|__ tutorials
|__ list.html
|__ single.html
|__index.html
My single tutorial content (new-tutorial.md):
+++
title = "My new Tutorial"
date: 2019-10-04T14:10:46+02:00
draft: false
type: tutorial
layout: tutorial
+++
# Custom Content Headline
There is no error message from hugo. I expect hugo to open the page "http://localhost:1313/tutorials/new-tutorial/ with the layout that lies in the file "layouts/tutorials/single.html"
You should not specify type: tutorial and type:tutorial in new-tutorial.md in your case.
Hugo will use layouts/tutorials/single.html by default for tutorial section, see https://gohugo.io/templates/lookup-order/#examples-layout-lookup-for-regular-pages
Final result for new-tutorial.md will look like
+++
title = "My new Tutorial"
date: 2019-10-04T14:10:46+02:00
draft: false
+++
# Custom Content Headline
Already solved the issue, the problem is in the type definition. Hugo by default gives the elements inside the tutorials folder, the type tutorials, if you change it to tutorial, you must make a subfolder with the tutorial htmls, that are the new type.
layouts
|__ _default
|__ list.html
|__ single.html
|__ posts
|__ list.html
|__ single.html
|__ tutorials
|__ list.html
|__ single.html
|__ tutorial
|__ list.html
|__ single.html
|__index.html
like it says in the documentation
In case I am not making my self clear, you can read about it here and here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With