# \[Solved\] Select files that are direct children of content, not in sub-folders

**URL:** <https://discourse.gohugo.io/t/solved-select-files-that-are-direct-children-of-content-not-in-sub-folders/10371>\
**Category:** support\
**Created:** [February 5, 2018, 11:52am UTC](https://discourse.gohugo.io/t/solved-select-files-that-are-direct-children-of-content-not-in-sub-folders/10371 "2018-02-05T11:52:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hawker65](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hawker65/32/5123_2.png) [@Hawker65](https://discourse.gohugo.io/u/Hawker65)\
**Post date:** [February 5, 2018, 11:52am UTC](https://discourse.gohugo.io/t/solved-select-files-that-are-direct-children-of-content-not-in-sub-folders/10371/1 "2018-02-05T11:52:09Z")

</div>

I installed and customised a theme that creates a single page out of multiple .md files. When creating a page, this theme takes into account any file in `content`, including those in sub-folders. I would like to create pages only from direct children, especially for the front page (the one at `localhost:1313`).

```
/content/
    child1
    child2
    section1/
        grandchild1

```

I want to build a page using only `child1` and `child2`, excluding `grandchild1`

I tried to set up an `index.md` file at the root of `content`, but this prevents me from accessing other pages.

I’m trying to find, if possible, a good `where` function usage to create this condition. Keep in mind that I’m a newbie and I’m not a Go programmer.

In terms of code, the following line includes all pages :

```
{{ range $index, $element := .Data.Pages}}

```

I would like to do something like :

```
{{ range $index, $element := where .InSection(.Data.Pages)}}

```

Unfortunately, I can’t get this to work.

Here is the full code :

```
<section id="services">

<!-- Page Content -->
{{ range $index, $element := .Data.Pages}}
    {{ if modBool $index 2 }}
    <div class="content-section-a">
    {{ else }}
    <div class="content-section-b">
    {{ end }}

        <div class="container">

            <div class="row">
                <div>
                    <hr class="section-heading-spacer">
                    <div class="clearfix"></div>
                    <h2 class="section-heading">{{ .Title }}</h2>
                    {{ .Content }}
                </div>
            </div>

        </div>
        <!-- /.container -->

    </div>
{{ end }}

</section>

```

Hugo env :

```
Hugo Static Site Generator v0.34 linux/amd64 BuildDate: 2018-01-22T12:06:40Z
GOOS="linux"
GOARCH="amd64"
GOVERSION="go1.9.2"
```

---

<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:** [February 5, 2018, 12:35pm UTC](https://discourse.gohugo.io/t/solved-select-files-that-are-direct-children-of-content-not-in-sub-folders/10371/2 "2018-02-05T12:35:39Z")

</div>

It seems to be that page bundles and the _new_ .Resources template variable are what you are looking for. I’m still trying to move my content into that sort of structure myself.

---

<div class="post-metadata">

**Author:** ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)\
**Post date:** [February 5, 2018, 1:02pm UTC](https://discourse.gohugo.io/t/solved-select-files-that-are-direct-children-of-content-not-in-sub-folders/10371/3 "2018-02-05T13:02:56Z")

</div>

You should ask the theme author for assistance.

---

<div class="post-metadata">

**Author:** ![Hawker65](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hawker65/32/5123_2.png) [@Hawker65](https://discourse.gohugo.io/u/Hawker65)\
**Post date:** [February 5, 2018, 1:08pm UTC](https://discourse.gohugo.io/t/solved-select-files-that-are-direct-children-of-content-not-in-sub-folders/10371/4 "2018-02-05T13:08:48Z")

</div>

Since I’ve customized the theme, the problem doesn’t really come from the theme. I’m trying to create a condition like `where .InSection .Data.Pages` but I don’t know how to code it properly.

Basically, I have the following line that takes every file into account :

```
{{ range $index, $element := .Data.Pages}}

```

I want to take only the file that are direct children of `content`, not the files in subfolders.

---

<div class="post-metadata">

**Author:** ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)\
**Post date:** [February 5, 2018, 1:10pm UTC](https://discourse.gohugo.io/t/solved-select-files-that-are-direct-children-of-content-not-in-sub-folders/10371/5 "2018-02-05T13:10:48Z")

</div>

If you want assistance with a template, please read and follow the guidelines at [Requesting Help](https://discourse.gohugo.io/t/requesting-help/9132?u=maiki), then someone will be able to help. 🙂

---

<div class="post-metadata">

**Author:** ![Hawker65](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hawker65/32/5123_2.png) [@Hawker65](https://discourse.gohugo.io/u/Hawker65)\
**Post date:** [February 5, 2018, 2:43pm UTC](https://discourse.gohugo.io/t/solved-select-files-that-are-direct-children-of-content-not-in-sub-folders/10371/6 "2018-02-05T14:43:52Z")

</div>

I solved it after multiple trials and errors :

```
{{ range $index, $element := where .Data.Pages "Section" .Section}}
```
