{{ $elements := index (split .CurrentSection "/") }} {{ $current_section_name := index $elements (sub (len $elements) 2) }} {{ $parent_section_name := index $elements (sub (len $elements) 3) }} {{ $top_section_name := index $elements (sub (len $elements) 4) }} {{ $baseSubsection := . }} {{ $subSubsection := . }} {{ if eq $top_section_name .Section }} {{ $baseSubsection = .Parent }} {{ end }} {{ if not .IsSection }} {{ $baseSubsection = .Parent.Parent }} {{ $subSubsection = .Parent }} {{ end }} {{ $indexRelPermalink := .RelPermalink }} {{ $layout := .Page.CurrentSection.Params.layout }} {{ $parentLayout := .Page.Parent.CurrentSection.Params.layout }} {{ define "subpages" }} {{ $indexRelPermalink := .indexRelPermalink }} {{ if .context.Pages }} {{ range .context.Pages}} {{ if eq .Kind "page" }} {{ end }} {{ template "subpages" (dict "indexRelPermalink" $indexRelPermalink "context" .) }} {{ end }} {{ end }} {{ end }}