# Not mainSections?

**URL:** <https://discourse.gohugo.io/t/not-mainsections/6951>\
**Category:** Uncategorized\
**Created:** [June 11, 2017, 12:10pm UTC](https://discourse.gohugo.io/t/not-mainsections/6951 "2017-06-11T12:10:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![STQOE](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/stqoe/32/3292_2.png) [@STQOE](https://discourse.gohugo.io/u/STQOE)\
**Post date:** [June 11, 2017, 12:10pm UTC](https://discourse.gohugo.io/t/not-mainsections/6951/1 "2017-06-11T12:10:19Z")

</div>

I’m using @budparr’s awesome [Ananke theme](https://github.com/budparr/gohugo-theme-ananke) as a base to build off and I’m wondering if there’s a way to exclude mainSections instead of including them?

mainSections are declared via params in the config.toml…  
\> {{/\* Define a section to pull recent posts from. For Hugo 0.20 this will default to the section with the most number of pages. \*/}}

> ```
> {{ $mainSections := .Site.Params.mainSections | default (slice "tips") }}
> {{/* Create a variable with that section to use in multiple places. */}}
> {{ $section := where .Site.RegularPages "Section" "in" $mainSections }}
> {{/* Check to see if the section is defined for ranging through it */}}
> {{ $section_count := len $section }}
> {{ if ge $section_count 1 }}
> {{/* Derive the section name */}}
> {{ $section_name := index (.Site.Params.mainSections) 0 }}
> 
> ```

---

<div class="post-metadata">

**Author:** ![budparr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/budparr/32/749_2.png) [@budparr](https://discourse.gohugo.io/u/budparr)\
**Post date:** [June 11, 2017, 12:21pm UTC](https://discourse.gohugo.io/t/not-mainsections/6951/2 "2017-06-11T12:21:00Z")

</div>

Is that to say you want to include a particular section?

It’s not documented, but `mainSections` allows you to define the section(s) in your config file. If there isn’t one defined, it automatically chooses the Section with the most documents.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [June 11, 2017, 12:23pm UTC](https://discourse.gohugo.io/t/not-mainsections/6951/3 "2017-06-11T12:23:48Z")

</div>

> [@STQOE](#):
>
> {{ $section := where .Site.RegularPages “Section” “in” $mainSections }}

To exclude you would do:

```auto
{{ $section := where .Site.RegularPages "Section" "not in" $mainSections }}

```

---

<div class="post-metadata">

**Author:** ![STQOE](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/stqoe/32/3292_2.png) [@STQOE](https://discourse.gohugo.io/u/STQOE)\
**Post date:** [June 11, 2017, 12:26pm UTC](https://discourse.gohugo.io/t/not-mainsections/6951/4 "2017-06-11T12:26:37Z")

</div>

A good theme’s the best documentation @budparr and thanks to yours I worked that. But I want my recent posts to come from all/any of my sections (except “Pages”) and I plan to be adding many, many new sections in the future so the thought of having to manually adjust the config file every time a new section is added seems laborious.

And it looks like @bep has made more Hugo magic (replying to this thread with a solution) so thank you both.
