# Where to define menus?

**URL:** <https://discourse.gohugo.io/t/where-to-define-menus/159>\
**Category:** support\
**Created:** [October 2, 2014, 2:55pm UTC](https://discourse.gohugo.io/t/where-to-define-menus/159 "2014-10-02T14:55:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tom/32/80_2.png) [@tom](https://discourse.gohugo.io/u/tom)\
**Post date:** [October 2, 2014, 2:55pm UTC](https://discourse.gohugo.io/t/where-to-define-menus/159/1 "2014-10-02T14:55:01Z")

</div>

Hi, I’ve been reading the documentation and see the section on menus but I’m not sure where to put the definition. The formatting doesn’t look like it belongs in the TOML file… Does it?

Thanks!

---

<div class="post-metadata">

**Author:** ![tatsushid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tatsushid/32/7219_2.png) [@tatsushid](https://discourse.gohugo.io/u/tatsushid)\
**Post date:** [October 2, 2014, 3:09pm UTC](https://discourse.gohugo.io/t/where-to-define-menus/159/2 "2014-10-02T15:09:03Z")

</div>

I put the menu definition in my `config.yaml` and it works. Of course, `config.toml` and `config.json` are also ok.

---

<div class="post-metadata">

**Author:** ![tom](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tom/32/80_2.png) [@tom](https://discourse.gohugo.io/u/tom)\
**Post date:** [October 2, 2014, 3:12pm UTC](https://discourse.gohugo.io/t/where-to-define-menus/159/3 "2014-10-02T15:12:25Z")

</div>

Oh I see. I was just looking at the documentation which shows YAML (and then later TOML) and didn’t realize you could do either.

It later goes on to mention the config file too. Can menus be defined elsewhere?

Thanks!

---

<div class="post-metadata">

**Author:** ![tatsushid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tatsushid/32/7219_2.png) [@tatsushid](https://discourse.gohugo.io/u/tatsushid)\
**Post date:** [October 2, 2014, 3:19pm UTC](https://discourse.gohugo.io/t/where-to-define-menus/159/4 "2014-10-02T15:19:26Z")

</div>

According to the code, you can put a menu definition in a front matter of each page.

---

<div class="post-metadata">

**Author:** ![oscar\_b](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/oscar_b/32/40_2.png) [@oscar\_b](https://discourse.gohugo.io/u/oscar_b)\
**Post date:** [October 2, 2014, 5:06pm UTC](https://discourse.gohugo.io/t/where-to-define-menus/159/5 "2014-10-02T17:06:51Z")

</div>

Make sure you read [http://discuss.gohugo.io/t/intro-to-toml/42/4](http://discuss.gohugo.io/t/intro-to-toml/42/4), it has some useful information about TOML that took me a while to figure out.

In the front matter of each content page you want in the menu, I have something like this:

```auto
+++
date = "2014-09-18T21:51:13+02:00"
title = "About Us"
[menu.main]
name = "About"
weight = 4
+++

```

One important thing to remember is that all table definitions in TOML needs to be _last_, since it just keeps adding variables that appears until the end or until the next table definition. If `name` in `[menu.main]` is left out, it will use the page title. `weight` is for determining the order of your menu items.

Then my `partials/nav.html`is something like this:

```auto
<nav>
	<ul>
		{{ range .Site.Menus.main }}
		<li><a href="{{ .Url }}">{{ .Name }}</a></li>
		{{end}}
	</ul>
</nav>

```

---

<div class="post-metadata">

**Author:** ![natefinch](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/natefinch/32/2136_2.png) [@natefinch](https://discourse.gohugo.io/u/natefinch)\
**Post date:** [October 2, 2014, 5:41pm UTC](https://discourse.gohugo.io/t/where-to-define-menus/159/6 "2014-10-02T17:41:24Z")

</div>

@oscar_b: modified your above post to change “array” to “table”, since that’s the more correct term for what menu is, in this case. An array is traditionally a list of the same thing, like `fruit = ["pear", "apple", "orange"]` whereas a table in toml is like a hashtable, or dictionary in other languages (or object in json) - a separate thing with it’s own name/value pairs.

Hope you don’t mind, just wanted to make sure the terminology was correct.

---

<div class="post-metadata">

**Author:** ![oscar\_b](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/oscar_b/32/40_2.png) [@oscar\_b](https://discourse.gohugo.io/u/oscar_b)\
**Post date:** [October 2, 2014, 5:44pm UTC](https://discourse.gohugo.io/t/where-to-define-menus/159/7 "2014-10-02T17:44:27Z")

</div>

> [@natefinch](#):
>
> Hope you don’t mind, just wanted to make sure the terminology was correct.

Not at all, thanks 🙂
