# Include subsection contents in main section

**URL:** <https://discourse.gohugo.io/t/include-subsection-contents-in-main-section/7338>\
**Category:** support\
**Created:** [July 6, 2017, 6:44pm UTC](https://discourse.gohugo.io/t/include-subsection-contents-in-main-section/7338 "2017-07-06T18:44:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cflipse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/cflipse/32/3510_2.png) [@cflipse](https://discourse.gohugo.io/u/cflipse)\
**Post date:** [July 6, 2017, 6:44pm UTC](https://discourse.gohugo.io/t/include-subsection-contents-in-main-section/7338/1 "2017-07-06T18:44:39Z")

</div>

Say that I have a set of mostly-alike pages divided into subsections. All the pages have the same type, but individual items can be categorized differently, hence dropping them into subsections:

- books/
  - non-fiction
    - [book1.md](http://book1.md)
    - [book2.md](http://book2.md)

  - novels
    - [novel1.md](http://novel1.md)
    - [novel3.md](http://novel3.md)

something like that. I can get the site to generate with the sub-pages put together, paginating etc correctly … except the books page is empty. I’d like to be able to either: list _all_ books from all subsections, or, filter the list to things with `featured: true` in the frontmatter, and I can’t quite figure out how to go about doing that.

It seems like there’s only one `list.html` allowed for the overall type, and attempting to override the `$paginator` inside an `_index.md` just results in the line being echoed on page. Anyone have any ideas on this?

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [July 6, 2017, 7:19pm UTC](https://discourse.gohugo.io/t/include-subsection-contents-in-main-section/7338/2 "2017-07-06T19:19:00Z")

</div>

1. Create a layout at `layouts/books/list.html`.
2. To add content or front matter to your rendered page, you’ll need to create a content file at `content/books/_index.md`.
3. You can use `.Data.Pages`, which will automatically pull from all the pages in that section.
4. Use the `where` keyword to filter…

```auto
{{range where .Data.Pages ".Params.featured" true}}
{{ end }}

```

If not, try `"Params.featured"`…sorry, can’t test right now…

---

<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:** [July 6, 2017, 7:20pm UTC](https://discourse.gohugo.io/t/include-subsection-contents-in-main-section/7338/3 "2017-07-06T19:20:51Z")

</div>

You can customize your list.html as you want per section with something like:

> ```
> {{ if eq .Section "non-fiction" }}
> .....
> {{ end }}
> 
> ```

Check out the official demo of Hugo nested sections: [http://hugotest.bep.is/](http://hugotest.bep.is/)

I haven’t experimented with nested sections yet, but in Hugo `/section/` is an alias of `type`.

So to render all posts in a main section (including the ones in nested sections) do this:

> {{ range $i, $e := (where .Site.Pages “Type” “non-fiction”) }}  
> …  
> {{ end }}
