{{- $page := . -}} {{- with .Page }}{{ $page = . }}{{ end -}} {{- $taxonomiesRoot := site.GetPage "section" "taxonomies" -}} {{- $trail := slice -}} {{- if $page }} {{- $isTaxonomy := or (eq $page.Kind "taxonomy") (eq $page.Kind "term") -}} {{- if and $isTaxonomy $taxonomiesRoot -}} {{- if not (in $trail $taxonomiesRoot) -}} {{- $trail = $trail | append $taxonomiesRoot -}} {{- end -}} {{- end -}} {{- range $page.Ancestors.Reverse -}} {{- if ne .RelPermalink "/" -}} {{- if not (in $trail .) -}} {{- $trail = $trail | append . -}} {{- end -}} {{- end -}} {{- end -}} {{- if eq $page.Kind "term" }} {{- with site.GetPage "taxonomy" $page.Data.Plural }} {{- range .Ancestors.Reverse -}} {{- if ne .RelPermalink "/" -}} {{- if not (in $trail .) -}} {{- $trail = $trail | append . -}} {{- end -}} {{- end -}} {{- end -}} {{- if not (in $trail .) -}} {{- $trail = $trail | append . -}} {{- end -}} {{- end -}} {{- else if eq $page.Kind "taxonomy" }} {{- if and (eq (len $trail) 0) (not $taxonomiesRoot) }} {{- with site.Home }} {{- if ne .RelPermalink "/" -}} {{- $trail = $trail | append . -}} {{- end -}} {{- end -}} {{- end -}} {{- end }} {{- end }} {{- if gt (len $trail) 0 -}} {{- end -}}