Hugo won't pick up list template for a type

Hi,

I’m struggling with type templates. Specifically, I’m struggling with the list.html template for a type. When I display a page for a specific type, e.g. article, it renders from the article/single.html page, which is what I expect. But, when I go to article page, it is rendering from the _default/list.html

My layouts structure is…

layouts
    _default
        list.html
        single.html
    article
        list.html
        single.html
    service
        list.html
        single.html

Each of the above .html files contains the full html for the page. E.g. article/single.html contains…

<!DOCTYPE html>
<html>
    {{ partial "head.html" . }}

<body>

    <div class="outerWrapper">

        {{ partial "header.html" . }}

        {{ partial "menu.html" . }}

        <div class="innerWrapper">
             <p>This is article single</p>
             {{ .Content }}

        </div>

  </div>

  {{ partial "footer.html" . }}

</body>

</html>

I know which file it’s being picked up from as I’ve included a line in the html to say what the file is. E.g.

This is article single

or

We're in default/list.html

I guess I’m not that far off as Hugo is picking up type/single.html, but I just don’t understand why it’s not picking up article/list.html

My site is on GitHub. https://github.com/ChrisHAdams/Lucent

You need to move that template from /layouts/article/list.html to /layouts/section/article.html

Same thing for service

Read the Hugo template look up order in the Docs.

Whenever you need to have a custom layout for a section it always goes under/layouts/section/section-name.html

2 Likes

@alexandros Hi - Yes, that was it. Now working as I need. Many thanks for the prompt solution. I like Hugo but was struggling with this and was close to just crafting the site in html. Again, many thanks.