# How menu multiple pages in folder

**URL:** <https://discourse.gohugo.io/t/how-menu-multiple-pages-in-folder/5934>\
**Category:** support\
**Created:** [March 26, 2017, 4:43pm UTC](https://discourse.gohugo.io/t/how-menu-multiple-pages-in-folder/5934 "2017-03-26T16:43:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edward](https://avatars.discourse-cdn.com/v4/letter/e/90db22/32.png) [@Edward](https://discourse.gohugo.io/u/Edward)\
**Post date:** [March 26, 2017, 4:43pm UTC](https://discourse.gohugo.io/t/how-menu-multiple-pages-in-folder/5934/1 "2017-03-26T16:43:16Z")

</div>

I have in “content” a folder named “about” with multiple [page.md](http://page.md) files in it which I want to link to from the menu.

In my config.toml file I have

```auto
[[menu.main]]
  name = "About"
  weight = 35
  identifier = "about"
  url = "/About/"

```

In the menu I only have About and clicking it gives me a page with no links titled “Abouts”. What am I doing incorrectly?

(I’m using the “Mainroad” theme.)

---

<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:** [March 27, 2017, 2:48pm UTC](https://discourse.gohugo.io/t/how-menu-multiple-pages-in-folder/5934/2 "2017-03-27T14:48:31Z")

</div>

I think you might need a list template. (Either `/layouts/_default/list.html` or `/layouts/section/about.html`:

For `/layouts/_default/list.html`

```auto
{{ range where .Site.Pages "Section" "about"}}
    Your code here
{{end}}

```

Basically you want to list all the pages in the /about/ section (any first subdirectory under /content/ is a section)

For `/layouts/section/about.html`

```auto
{{ range .Data.Pages }}
    Your code here
{{end}}

```

The context of .`Pages (.Data.Pages and .Site.Pages)` changes from one list template to another. `.Data.Pages` will be in the context of the current section node.

---

<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:** [March 27, 2017, 5:10pm UTC](https://discourse.gohugo.io/t/how-menu-multiple-pages-in-folder/5934/3 "2017-03-27T17:10:47Z")

</div>

I’m sorry, I didn’t see that you were using the mainroad theme.

Mainroad theme only has one list file, `layouts/_default/list.html` which contains:

```auto
{{- $paginator := .Paginate ( where .Data.Pages "Section" "post") }}

```

So it’s only going to display pots from the “post” section (/content/post)

you have two options here:

you can modify the default list page line #9 to

```auto
{{- $paginator := .Paginate .Site.Pages }}

```

or

you can copy `layouts/_default/list.html` (and don’t edit it) to `layouts/section/about.html` so your html layout can remain consistent with the theme, and modify line #9 to

```auto
{{- $paginator := .Paginate ( where .Data.Pages "Section" "about") }}

```

This way you can have a list template for your /about section.

Whichever option works best for you. I’m not sure if this will throw off anything else in the theme, but that’s how you could articles from the /about section.

---

<div class="post-metadata">

**Author:** ![Edward](https://avatars.discourse-cdn.com/v4/letter/e/90db22/32.png) [@Edward](https://discourse.gohugo.io/u/Edward)\
**Post date:** [March 27, 2017, 6:36pm UTC](https://discourse.gohugo.io/t/how-menu-multiple-pages-in-folder/5934/4 "2017-03-27T18:36:58Z")

</div>

Thank you Hash\_Borgir. I had thought that the list template was more or less for pasting bits together into one page, and had not realized that it would be used to create a list of pages with links.

I followed your second option, assuming you mean to copy the code in the layouts directory in the root of the project and not inside the themes directory. I modified the code based on the second option. I can bring the pages up by entering the url into the browser’s url bar ([x.com/about/faq/](http://x.com/about/faq/)) so I know they are being built. However, I still cannot get to them through menu navigation. My menu nav is still as in my first post.

Let me make this very concrete. I have content/about/ and inside the about folder I have two files ([about.md](http://about.md) and [faq.md](http://faq.md)). I want people to be able to click through from the main menu and have option to click on either link and go to either page. I’m still not sure where I am off track. This is a very primitive need so I’m sure I’m getting something very simple wrong. Hugo seems so elegant. But the documentation still has me confused. Thanks in advance for help rendered!

---

<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:** [March 27, 2017, 8:43pm UTC](https://discourse.gohugo.io/t/how-menu-multiple-pages-in-folder/5934/5 "2017-03-27T20:43:07Z")

</div>

In addition to the list page at /layouts/section/about.html, you can simply just create two submenu entries using the “parent=” directive.

See [https://gohugo.io/content-management/menus/#what-is-a-menu-in-hugo](https://gohugo.io/content-management/menus/#what-is-a-menu-in-hugo) for more information.

Just create two submenus and link them to individual pages, as well as having a list template so /about can list both pages.

```auto
[[params.menu]]
  name = "About"
  weight = 35
  identifier = "about"
  url = "/about/about"

[[params.menu]]
  name = "FAQ"
  weight = 36
  identifier = "about"
  url = "/about/faq"
  parent = "about"

```

I am not sure… but I think this is how you would create your sub menus, linking to each page.

---

<div class="post-metadata">

**Author:** ![Edward](https://avatars.discourse-cdn.com/v4/letter/e/90db22/32.png) [@Edward](https://discourse.gohugo.io/u/Edward)\
**Post date:** [March 27, 2017, 9:38pm UTC](https://discourse.gohugo.io/t/how-menu-multiple-pages-in-folder/5934/6 "2017-03-27T21:38:57Z")

</div>

hash\_Borgir, when I did that the About menu went away but then by adding

```auto
menu = ["main"]

```

in the front matter of [about.md](http://about.md) and [faq.md](http://faq.md) they were added to the main menu (not quite where I want them).

In the link to the documentation (I see .20 has landed) an example is given in YAML

```auto
menu:
  main:
    parent: 'extras'
    weight: 20

```

How would I format that in TOML?

I think the documentation would benefit from adding several small actual use cases. I read the documentation again but I am still not clear about what must be in config.toml and what must be in the front matter of the page I am linking to. Can it be done either way or must it be in both places?

---

<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:** [March 28, 2017, 3:50am UTC](https://discourse.gohugo.io/t/how-menu-multiple-pages-in-folder/5934/7 "2017-03-28T03:50:25Z")

</div>

The reason why it might have vanished is because my information might be from a few older versions. I still need to catch up.

```auto
		{{- range sort .Site.Menus.main }}
		<li class="menu__item {{if or ($currentNode.IsMenuCurrent "main" .) ($currentNode.HasMenuCurrent "main" .) }}menu__item--active{{end}}"><a class="menu__link" href="{{ .URL }}">{{ .Name | upper }}</a></li>
		{{- end }}

```

This is the code for the menu.html partial for the mainroad theme. It’s just iterating over .Site.Menus.main. I am used to having done .Site.Params.menu.main etc. Change the code to this, and your menu will come back and possibly work:

```auto
[menu]
[[menu.main]]
  name = "About"
  weight = 35
  identifier = "about"
  url = "/about/about"

[[menu.main]]
  name = "FAQ"
  weight = 36
  identifier = "about"
  url = "/about/faq"
  parent = "about"

```

As for your question bout yaml-\>toml, try something like this, though I’m not sure what this would accomplish.:

```auto
[menu]
[[menu.main]]
    parent = "extras"
    weight = 20

```
