Why my layout is not used, but single.html instead?

Hi there

I’ve the following situation:

The question is, why is my about.html layout not used, but the _default/single.html?

I want that the about content is a section on the homepage, which should be rendered with a section template. Is this the way to achieve it?

Thank you in advance!
Robin

Give it a type= “page” and then move the template under /layouts/page/single.html

1 Like

That works flawlessly. Thank you!

After reading the documentation about that topic, this behavior is not intuitive to me. Is it done like this by intention?

Hugo’s template look up order has been like that for ages.

I also had some difficulty wrapping my head around it when I first started using Hugo.

1 Like

First of all there is no about.html “layout file”, it’s just a partial. A partial does not get picked up automatically… you need to call it using {{ partial “foo.html” . }}`.

Any .md file in content that is not _index.md will automatically use the single.html (by default, if type or layout is not overridden in the front-matter).

If you want to render the about page as a section, make it a section… move content/about.md to content/about/_index.md.

For further reading on the _index.md, I’d suggest:

1 Like

@openscript I suggest that you look at the auto-generated documentation on layout lookup order here:

It’s very much consistent through the different cases, and once you carefully look at few of the examples in there, that consistency with “click” for you too. I believe that the layout lookup consistency and flexibility in Hugo is not getting the credit it deserves :slight_smile:

It wasn’t a partial. Look again the above screenshot of his directory tree.

1 Like

What am I missing? I see layouts/partials/about.html.

Nevermind, I realized my mistake… the partials/ directory is probably not expanded based on that arrow direction.

Thank you very much for the explanation. :slightly_smiling_face:

If I do like you described with the sections, the about page is not rendered within the home page.

The layout about.html consists of: {{ .Content }}