diff --git a/layouts/partials/menu.html b/layouts/partials/menu.html
index c5d4fd78e2..ae65bb0f3c 100644
--- a/layouts/partials/menu.html
+++ b/layouts/partials/menu.html
@@ -16,8 +16,30 @@
{{ $page := . }}
- {{ range $key , $value := .Site.Sections }}
+ {{ if .Site.Params.menu }}
+ {{ $.Scratch.Set "menuItems" (slice) }}
+ {{ range $i, $key := .Site.Params.menu }}
+ {{ if isset $page.Site.Sections $key }}
+ {{ $.Scratch.Add "menuItems" $key }}
+ {{ else }}
+
+ {{ printf "Unknown section '%s' found in site menu" $key }}
+
+ {{ end }}
+ {{ end }}
+ {{ else }}
+ {{ $.Scratch.Set "menuItems" .Site.Sections }}
+ {{ end }}
+ {{ $menuItems := $.Scratch.Get "menuItems" }}
+ {{ range $i, $key := $menuItems }}
{{ if ne $key "" }}
+
+ {{ if not $.Site.Params.menu }}
+ {{ $.Scratch.Set "currentItem" (index $page.Site.Sections $i) }}
+ {{ else }}
+ {{ $.Scratch.Set "currentItem" (index $page.Site.Sections $key) }}
+ {{ end }}
+ {{ $value := $.Scratch.Get "currentItem" }}
{{ $first := (index $value 0).Page }}
-
@@ -32,13 +54,13 @@
{{ end }}
- {{ if gt .Pages.Len 1}}
+ {{ if gt $value.Len 1}}