# How to list pages from each section and subsection?

**URL:** <https://discourse.gohugo.io/t/how-to-list-pages-from-each-section-and-subsection/13950>\
**Category:** support\
**Created:** [August 30, 2018, 3:00pm UTC](https://discourse.gohugo.io/t/how-to-list-pages-from-each-section-and-subsection/13950 "2018-08-30T15:00:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hash\_Borgir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hash_borgir/32/6655_2.png) [@Hash\_Borgir](https://discourse.gohugo.io/u/Hash_Borgir)\
**Post date:** [August 30, 2018, 3:00pm UTC](https://discourse.gohugo.io/t/how-to-list-pages-from-each-section-and-subsection/13950/1 "2018-08-30T15:00:30Z")

</div>

![sections](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/1/19cbc0d118c0b29adf242066b00c92bd5ed29305.jpeg)

I want to go to /psychedelics

and see a list of all articles in the /psychedelics content section, from all sub sections  
I want to go /psychedelics/mushroom and see only all the articles from that sub-section  
I want to go to /news and only see all the /news articles

And have them paginated. I can’t seem to figure out a solution to this. My current default/list.html template has this:

```auto
{{ $paginator := .Paginate .Pages }}
{{ range $i, $e := where ($paginator.Pages) ".Params.hidden" "!=" true }}

```

I created /layouts/section/psychedelics.html

```auto
{{ $paginator := .Paginate (where .Data.Pages "Type" "psychedelics") }}
{{ range $paginator.Pages }}

```

and that only lists one article. Instead of all of them in the /psychedelics/ content dir.

and when I to go [site.com/psychedelics/](http://site.com/psychedelics/) it only shows one article. And that article is from psychedelics/info/ sub section, so I’m not sure what is going on. I’ve hit a dev roadblock here.

Please advise.

I have tried:

```auto
{{ $paginator := .Paginate .Site.RegularPages (where .Site.RegularPages "section" "psychedelics") }}
{{ range $i, $e := $paginator.Pages }}

```

with error:

`Building sites … ERROR 2018/08/30 10:28:40 Error while rendering "taxonomy" in "categories/microdosing/": template: _default/list.html:67:47: executing "_default/list.html" at <where .Site.RegularP...>: error calling where: section isn't a field of struct type *hugolib.Page`

UPDATE:

I did this:

/layouts/sections/psychedelics.html

```auto
{{ $paginator := .Paginate (where .Site.RegularPages "Type" "psychedelics") }}
{{ range $paginator.Pages }}

```

and now all the pages from the psychedelics shows up, from all sub sections.

Is there a way to do this in the default list template, so I don’t have to make a sectiont list template for each top level section?

---

<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:** [August 30, 2018, 9:49pm UTC](https://discourse.gohugo.io/t/how-to-list-pages-from-each-section-and-subsection/13950/2 "2018-08-30T21:49:04Z")

</div>

> [@Hash\_Borgir](#):
>
> Is there a way to do this in the default list template, so I don’t have to make a sectiont list template for each top level section?

You can do that by checking for the permalink of each top level section…

eg

```
{{ if in (.Permalink | string) "/psychedelics/" }}<—-Layout for the psychedelics section —->{{ end }}

```

PS That is how I develop Hugo projects. I have one template to rule all lists. It’s easier to maintain for me.
