Skip to content
Permalink
Browse files

Add dynamic header menu using Hugo Menu's

Added dynamic header menu, Hugo-style
Template from https://gohugo.io/templates/menu-templates
Removed unused i18n

See #29
  • Loading branch information...
gavinr authored and EmielH committed Oct 9, 2019
1 parent 636e30e commit 7a84b69b223dd9f69c58b90164ff3b35a4af3161
Showing with 46 additions and 8 deletions.
  1. +36 −0 README.md
  2. +0 −6 i18n/en.toml
  3. +10 −2 layouts/partials/header-menu.html
@@ -36,6 +36,42 @@ Alternatively, you can tell Hugo to use the theme with the `server` command.
hugo server -t tale
```

#### Menu

The top menu uses [Hugo Menus](https://gohugo.io/content-management/menus/), with the name of the menu being `main`. To turn on the menu, follow the steps there - you can either add something like this to the front-matter of your pages:

```
---
menu: "main"
---
```

... or you can add a menu section to your `config` file:

```
sectionPagesMenu = "main"
```

Or if you want more control, add a specific entry for each item in your menu:

```
[menu]
[[menu.main]]
identifier = "about"
name = "About"
title = "About"
url = "/about/"
weight = 0
[[menu.main]]
identifier = "posts"
name = "Posts"
title = "Posts"
url = "/posts/"
weight = 0
```

For menu internationalization/translation, see [Multilingual Mode: Menus](https://gohugo.io/content-management/multilingual/#menus).

### Additional information

For more information, read the official [setup guide](https//gohugo.io/overview/installing/) of Hugo.
@@ -1,9 +1,3 @@
[posts]
other = "Posts"

[about]
other = "About"

[writtenBy]
other = "Written by"

@@ -1,4 +1,12 @@
<ul>
<li><a href="{{ "about" | relURL }}">{{ i18n "about" }}</a></li>
<li><a href="{{ "/" | relURL }}">{{ i18n "posts" }}</a></li>
{{ $currentPage := . }}
{{ range .Site.Menus.main }}
<li>
<a href="{{ .URL }}">
{{ .Pre }}
<span>{{ .Name }}</span>
{{ .Post }}
</a>
</li>
{{ end }}
</ul>

0 comments on commit 7a84b69

Please sign in to comment.
You can’t perform that action at this time.