List template in section folder isn't used

In the content folder I have a “blog” folder with a few markdown files
In the layouts folder, I have a “blog” folder with both a single.html and list.html template.

The single.html template is being used to render the individual files as expected, but the list template is ignored and the one in _default is used instead. According to the docs, I think this is supported, but I’m stumped as to why it’s not working.

You ought to share the templates you are using, so we can reproduce your results. :slight_smile:

Sure. In trying to diagnosis the problem, I reduced the templates to the absolute minimum.
In /layouts/_default/baseof.html I have:

{{ block "main" . }} {{ .Content }} {{ end }} `

in /layout/_default/list.html I have:
{{ define "main" }}_default/list{{ end }}

in /layout/blog/list.html I have:
{{ define "main" }}blog/list{{ end }}

after building the site, if I go to /blog/ I get:

while individual files in the blog folder of content are rendered using the single template in the layout/blog folder.

What version of Hugo are you using? Find out quickly with hugo version.

Hugo Static Site Generator v0.18.1 BuildDate: 2017-04-11T16:12:49-05:00

The blog folder you set up in layouts is only for the individual views, like “single.” You want to put your blog list view template in a section folder, like this:


Check out the work-in-progress new docs site. It might be more helpful for you:

I guess I don’t understand. Isn’t the second item in the list exactly what I have?

Where you have the template blog/list you want section/blog.html


Render each individual page (single) and the list template (section/blog) from a template other than the default:


It may seem counterintuitive at first to arrange the layouts this way, but the blog folder contains all the views for a single blog item, so aggregate pages can’t go in there. Make sense?

What Hugo version are you using? The list templates for sections should be ore intuitive in Hugo >= 0.20.

I posted the version above.

According to the documentation you linked to, I understand that the /section/blog.html is the first choice template, followed by what I would expected to be /blog/list.html, at least that’s what the documentation appears to say to me.

The live documentation is for Hugo 0.20.

You’re right. As @bep pointed out, the documentation is for a later version of Hugo than you are using. You should be able to set it up as I mentioned above, or upgrade Hugo to the latest. Sorry to confuse you. I tend to link to the docs automatically.

1 Like