Cannot make specific layouts based on content section

Hello, Hugo community

I am trying to create a specific layout based on the content section. I read the link about Hugo’s templates lookup-order - https://gohugo.io/templates/lookup-order/ and I’ve also read the post How to create a specific layout and it seems that the custom single pages that I create for each section uses the _default single.html layout. The content section I want to customize is team. I was able to make a customization for the list layout. But I am having problems with the single page layout.

From my understanding to create a custom layout all I need to do is create a folder with the same name as content in themes/layouts/nameofContent and create a single.html file. I even tried overwritting the layout in the route folder layouts and it did not work.

Here is the file sturcture of my project.

    basic
        layouts
           _default
                baseof.html
                list.html
                month.html
                single.html
                year.html
           team
               list.html
               single.html

And here is the github link to my project

themes/basic/layouts/team

themes/basic/layout/_default

In the frontmatter of content that resides under said section you are using the parameter type.

Type is an alias of Section see here for the explanation.

Therefore by assigning the content under /team/ the parameter type: "Core Committee Member" you are basically disabling the inheritance of the templates under /layouts/team/

Rename that parameter to something else and the templates will be picked up.

To avoid such problems in the future also read the list of Predefined variables that Hugo uses and only use them when you need to override the default behaviour.

Also please avoid posting long titles in topics as it pollutes the forum. Be concise.

Thank you.

1 Like

Thank you. I made the changes and it worked.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.