How to list pages from each section and subsection?

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:

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

I created /layouts/section/psychedelics.html

{{ $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/ 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:

{{ $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

{{ $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?

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.