{{- $currentPage := . }} {{- range .Site.Menus.main.ByWeight -}} {{- template "menu-item" dict "menuEntry" . "currentPage" $currentPage -}} {{- end -}} {{- define "menu-item" -}} {{- $currentPage := .currentPage -}} {{- $showvisitedlinks := .Site.Params.showVisitedLinks -}} {{- with .menuEntry -}} {{- $menuEntry := . -}} {{- $isCurrent := $currentPage.IsMenuCurrent .Menu . -}} {{- $isAncestor := $currentPage.HasMenuCurrent .Menu . -}} {{- $children := .Children -}} {{- $numberOfChildren := (len $children) }} {{- if ne $numberOfChildren 0 -}} {{- if ne .Page nil -}} {{- with .Page -}} {{- $alwaysOpen := .Params.alwaysopen -}}