Where to define menus?

Make sure you read 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:

+++
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.htmlis something like this:

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