diff --git a/layouts/partials/navigation_level.html b/layouts/partials/navigation_level.html
index 9b2f901ed071..28b30c0673e0 100644
--- a/layouts/partials/navigation_level.html
+++ b/layouts/partials/navigation_level.html
@@ -23,7 +23,7 @@
{{ end }}
{{ end }}
-
+
{{ range $pages }}
{{ $pageLocation := (path.Dir (path.Dir .File.Dir)) }}
{{ if and (eq $parentDir $pageLocation) (not .Params.draft) }}
@@ -42,22 +42,28 @@
{{ end }}
{{ if not .IsPage }}
- -
+
-
{{ $collapse := not (.IsAncestor $current) }}
{{ if eq . $current }}
{{ $collapse = true }}
{{ end }}
- {{if lt (len $pageLocation) 6 -}}
- {{ $linktitle}}
- {{ partial "navigation_level.html" (dict "pages" $pages "parent" . "current" $current "collapse" false "top" false "labelledby" "" ) .CurrentSection }}
- {{ else if (.CurrentSection.IsAncestor $current) }}
- {{ $linktitle}}
- {{ partial "navigation_level.html" (dict "pages" $pages "parent" . "current" $current "collapse" $collapse "top" false "labelledby" "" ) }}
- {{- else -}}
- {{ $linktitle}}
- {{ partialCached "navigation_level.html" (dict "pages" $pages "parent" . "current" $current "collapse" $collapse "top" false "labelledby" "" ) .CurrentSection }}
- {{- end -}}
+ {{ if lt (len $pageLocation) 6 }}
+ {{ $linktitle }}
+ {{ if and .CurrentSection (ne .CurrentSection .) (ne .CurrentSection $parent) (ne .CurrentSection $current) .CurrentSection.Pages }}
+ {{ partial "navigation_level.html" (dict "pages" .CurrentSection.Pages "parent" . "current" $current "collapse" false "top" false "labelledby" "") }}
+ {{ end }}
+ {{ else if .CurrentSection.IsAncestor $current }}
+ {{ $linktitle }}
+ {{ if and .CurrentSection (ne .CurrentSection .) (ne .CurrentSection $parent) (ne .CurrentSection $current) .CurrentSection.Pages }}
+ {{ partial "navigation_level.html" (dict "pages" .CurrentSection.Pages "parent" . "current" $current "collapse" $collapse "top" false "labelledby" "") }}
+ {{ end }}
+ {{ else }}
+ {{ $linktitle }}
+ {{ if and .CurrentSection (ne .CurrentSection .) (ne .CurrentSection $parent) (ne .CurrentSection $current) .CurrentSection.Pages }}
+ {{ partial "navigation_level.html" (dict "pages" .CurrentSection.Pages "parent" . "current" $current "collapse" $collapse "top" false "labelledby" "") }}
+ {{ end }}
+ {{ end }}
{{ else }}
-