{{ define "main" }} {{ $elements := index (split .CurrentSection "/") }} {{ $top_section_name := index $elements (sub (len $elements) 4) }} {{ $baseSubsection := . }} {{ if eq $top_section_name .Section }} {{ $baseSubsection = .Parent }} {{ end }} {{ if not .IsSection }} {{ $baseSubsection = .Parent.Parent }} {{ end }}