# Confused about section page templates

**URL:** <https://discourse.gohugo.io/t/confused-about-section-page-templates/16547>\
**Category:** Uncategorized\
**Created:** [January 22, 2019, 10:53pm UTC](https://discourse.gohugo.io/t/confused-about-section-page-templates/16547 "2019-01-22T22:53:21Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![blablabla](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/blablabla/32/6940_2.png) [@blablabla](https://discourse.gohugo.io/u/blablabla)\
**Post date:** [January 22, 2019, 10:53pm UTC](https://discourse.gohugo.io/t/confused-about-section-page-templates/16547/1 "2019-01-22T22:53:21Z")

</div>

see my layouts for my “shows” section: [https://gitlab.com/fustkilas/oovoo/tree/master/layouts/shows](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://gitlab.com/fustkilas/oovoo/blob/master/content/shows/donut/_index.md)  
([https://brud.xyz/shows/donut/](https://brud.xyz/shows/donut/))

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

what template do i use for this?

---

<div class="post-metadata">

**Author:** ![brunoamaral](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/brunoamaral/32/21144_2.png) [@brunoamaral](https://discourse.gohugo.io/u/brunoamaral)\
**Post date:** [January 22, 2019, 11:15pm UTC](https://discourse.gohugo.io/t/confused-about-section-page-templates/16547/2 "2019-01-22T23:15:55Z")

</div>

If memory serves me right, `shows/list.html`

Take a look at this:

> **[Hugo's Lookup Order](https://gohugo.io/templates/lookup-order/)**
>
> Hugo searches for the layout to use for a given page in a well defined order, starting from the most specific.

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.

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [January 22, 2019, 11:49pm UTC](https://discourse.gohugo.io/t/confused-about-section-page-templates/16547/3 "2019-01-22T23:49:55Z")

</div>

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](https://gohugo.io/content-management/sections/#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`](https://gohugo.io/functions/range/#readout) function and use the [`.Sections`](https://gohugo.io/content-management/sections/#section-page-variables-and-methods) variable.

---

<div class="post-metadata">

**Author:** ![blablabla](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/blablabla/32/6940_2.png) [@blablabla](https://discourse.gohugo.io/u/blablabla)\
**Post date:** [January 23, 2019, 8:53am UTC](https://discourse.gohugo.io/t/confused-about-section-page-templates/16547/4 "2019-01-23T08:53:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [January 23, 2019, 9:06am UTC](https://discourse.gohugo.io/t/confused-about-section-page-templates/16547/5 "2019-01-23T09:06:24Z")

</div>

`_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`

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [January 23, 2019, 9:24am UTC](https://discourse.gohugo.io/t/confused-about-section-page-templates/16547/6 "2019-01-23T09:24:59Z")

</div>

> [@brunoamaral](#):
>
> `shows/list.html`

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).

---

<div class="post-metadata">

**Author:** ![blablabla](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/blablabla/32/6940_2.png) [@blablabla](https://discourse.gohugo.io/u/blablabla)\
**Post date:** [January 23, 2019, 2:50pm UTC](https://discourse.gohugo.io/t/confused-about-section-page-templates/16547/7 "2019-01-23T14:50:30Z")

</div>

i am even more confused now

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

> **[Fust Kilas / oovoo](https://gitlab.com/fustkilas/oovoo)**
>
> GitLab.com

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?

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [January 23, 2019, 3:19pm UTC](https://discourse.gohugo.io/t/confused-about-section-page-templates/16547/8 "2019-01-23T15:19:08Z")

</div>

> [@blablabla](#):
>
> 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](https://gohugo.io/functions/range/#readout)  
grouping content: [collections.Group | Hugo](https://gohugo.io/functions/group/#readout)  
or even better go through the complete templates introduction: [Templating | Hugo](https://gohugo.io/templates/introduction/)

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](https://gitlab.com/fustkilas/oovoo/blob/master/layouts/section/shows.html)

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.

---

<div class="post-metadata">

**Author:** ![Leo\_Merkel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/leo_merkel/32/3321_2.png) [@Leo\_Merkel](https://discourse.gohugo.io/u/Leo_Merkel)\
**Post date:** [January 23, 2019, 5:33pm UTC](https://discourse.gohugo.io/t/confused-about-section-page-templates/16547/9 "2019-01-23T17:33:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![blablabla](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/blablabla/32/6940_2.png) [@blablabla](https://discourse.gohugo.io/u/blablabla)\
**Post date:** [January 23, 2019, 7:48pm UTC](https://discourse.gohugo.io/t/confused-about-section-page-templates/16547/10 "2019-01-23T19:48:34Z")

</div>

@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](https://gitlab.com/fustkilas/oovoo/tree/master/layouts/shows)

ciao

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [January 23, 2019, 7:51pm UTC](https://discourse.gohugo.io/t/confused-about-section-page-templates/16547/11 "2019-01-23T19:51:22Z")

</div>

Cool. I’m happy you sorted it out @blablabla 👍
