Why don't sub-sections use the list.html template?

I’ve structured my Hugo project this way:

content
└─ blog
   └─ 2022
      ├─ 06
      │  └─ a.md
      └─ 07
         └─ b.md
layouts
└─ _default
   └─ list.html

My list.html says:

{{ range .Data.Pages  }}
    {{ .Render "summary" }}
{{ end }}

My config.yaml says:

permalinks:
  blog: /blog/:year/:month/:slug/

As expected, a.md appears under example.org/blog/2022/06/a/ and b.md under example.org/blog/2022/07/b/.

Also, list.html is applied to the blog section so that under example.org/blog a list appears that includes both a.md and b.md. However, this doesn’t work for any of the sub-sections.

Why is that? Do I have to manually set up an _index.md file for each sub-section to let the visitor browse example.org/blog/2022, example.org/blog/2022/06 and example.org/2022/07?

Thank you!

Why don’t you test it and see the result? A branch bundle needs an _index.md file.

1 Like

I have added an _index.md for each sub-section, changed my list.html to {{ partial "summary-recursive" . }} and added this summary-recursive.html in layouts\partials:

{{ range .Data.Pages  }}
  {{ if not .IsSection }}
    {{ .Render "summary" }}
  {{ end }}
{{ end }}

{{ if .Sections }}
  {{ range .Sections }}
    {{ partial "summary-recursive.html" . }}
  {{ end }}
{{ end }}

Now, it works just like I wanted it to.

1 Like

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