Confused about section page templates

see my layouts for my “shows” section: https://gitlab.com/fustkilas/oovoo/tree/master/layouts/shows

now, my individual “shows” pages are turning out just fine, using the list.html template

such as: https://gitlab.com/fustkilas/oovoo/blob/master/content/shows/donut/_index.md
(https://brud.xyz/shows/donut/)

but now i want a page one level above, at https://brud.xyz/shows/

what template do i use for this?

If memory serves me right, shows/list.html

Take a look at this:

I always get confused about which template file is being used. To fix it, I now make sure that the body classes include the name of the file being generated.

Actually the relevant template should be placed under /layouts/section/shows.html/

EDIT
Also I will give you one more hint @blablabla (before you say that you still do not see anything rendered with the template path I specified above).

The /shows/ section (as things are currently setup) does not contain regular .Pages, but instead Nested Sections due to your use of _index.md in every directory. Had you used index.md then these directories would have been regular .Pages.

So to populate the list under /shows/ (while keeping everything as is), you need to wrap everything right after the <main> tag within a range function and use the .Sections variable.

if i use index.md and not _index.md, then what do i need for /shows/?

_index.md --> list template used
index.md --> regular page template used

Therefore a simple range function to render these regular pages should be enough.

i.e. range .Pages

One last thing from me. The above template lookup PATH suggested by @brunoamaral is also correct.

However it all comes down to personal preference when it comes to maintaining a project.

Say you need custom layouts for several section lists.
With the above PATH you would need to create directories for each section under /layouts/<Section Name>/list.html
With the PATH I suggested you only need to create one directory under /layouts/section/<Section Name>.html

I always prefer to have as few directories as possible in a Hugo project (I h8 repetitive clicks).

i am even more confused now

check my new layout, where i cleaned up as per @alexandros suggestion

now, i wanna have a layout for brud.xyz/shows/ which collects info from the Pages within /shows/ folder. What layout should i use? And how to collect data?

These questions are fundamental and out of scope here. You need to read the Docs about:
range: range | Hugo
grouping content: collections.Group | Hugo
or even better go through the complete templates introduction: Templating | Hugo

And your issue is not a template lookup order issue.
You have not included any function to render the posts in your list page under: Files · master · Fust Kilas / oovoo · GitLab

Please re-read the replies I gave above and the links that I am posting to the Docs and if you still fail to render these posts in your list then ask again.

But we need to see some kind of working code.

We are not going to write the code for you. I’m sorry that’s the way it goes.

EDIT

Also with your latest commit you turned the /shows/ section into a regular page by changing the _index.md to index.md

As I said above

_index.md → Is for list pages = list template
index.md → regular page = single page template

You need to revert the change you introduced in your last commit to turn this directory into a Hugo Section again.

Also do keep the index.md under the various subfolders so that these are .Pages for you to render after reading the links I posted above.

1 Like

Perhaps this helps:
https://discourse.gohugo.io/t/my-experiences-with-hugos-template-lookup-order/9959/3

@alexandros indeed, i was hasty. apologies.

i figured it out! it was quite simple.

just to be extra super duper sure, i put my template for /shows/ under /layouts/shows/list.html

and for individual pages under /layouts/shows/single.html

this way, i get the best of all worlds: all “shows” templates under one folder, and individual pages accessible as .Pages

it finally clicked for me, thanks to @alexandros and all of you who are spending your personal time fixing my problems, thank you

for future reference, here is the template file: https://gitlab.com/fustkilas/oovoo/tree/master/layouts/shows

ciao

2 Likes

Cool. I’m happy you sorted it out @blablabla :+1: