Cannot override /_default/list.html

I’m trying to create different list.html templates for different sections:

content/something/2007/_index.md, article1.md, article2.md, article3.md
content/something/2008/_index.md article1.md, article2

The goal is to list the 2007 and 2008 sections in different ways.

The default list I want to override.
themes/my-theme/layouts/_default/list.html

First I tried to adjust the theme, so I added the following layout inside the theme:

themes/mytheme/layouts/something/2007/list.html
themes/mytheme/layouts/something/2008/list.html

It didn’t work, themes/my-theme/layouts/_default/list.html was loaded.

Then I tried to adjust the project root:

/content/something/2007/_index.md, article1.md, article2.md, article3.md
/content/something/2008/_index.md article1.md, article2

/layouts/something/2007/list.html
/layouts/something/2008/list.html

This didn’t work either.

Is this the correct approach and can this be achieved in this way?

When one of these two desired /2007/list.html and /2008/list.html was placed in /temes/my-theme/layouts/_default/list.html then that view would work.

This has been tested in a local development environment.

Environment.:

Windows 10,
hugo v0.123.2-929b91fe75cb0d041f22b4707700dfc117115ad4+extended windows/amd64 BuildDate=2024-02-22T15:27:15Z VendorInfo=gohugoio
go version go1.22.0 windows/amd64

Ubuntu 22.04,
hugo v0.123.2-929b91fe75cb0d041f22b4707700dfc117115ad4+extended linux/amd64 BuildDate=2024-02-22T15:27:15Z VendorInfo=snap:0.123.2
go version go1.22.0 linux/amd64

Notes:
When starting the “hugo server” server, a /public/ folder is always created, I’m not sure if this is correct.

No. See https://gohugo.io/templates/lookup-order/#target-a-template.

Yes, it is. With v0.123.0 hugo server renders to disk. If you want to render to memory, use the renderToMemory flag.

Thank you, jmooring. It’s working now.

1 Like

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