{{- $page := .page }}
{{- $to := $page }}
{{- $pageurl := partial "permalink.gotmpl" (dict "to" $page) }}
{{- $lasturl := partial "permalink.gotmpl" (dict "to" $page) }}
{{- if .dirOnly }}
  {{- $page = $page.Parent }}
  {{- $to = $page }}
  {{- $lasturl = partial "permalink.gotmpl" (dict "to" $page) }}
{{- end }}
{{- $depth := add 1 (int (partial "_relearn/pageDepth.gotmpl" (dict "page" $page))) }}
{{- $breadcrumb := slice }}
{{- range seq $depth }}
  {{- if $to }}
    {{- $title := partial "title.gotmpl" (dict "page" $to "linkTitle" true) }}
    {{- if partial "_relearn/pageIsSpecial.gotmpl" $to }}
      {{- break }}
    {{- else if or $title (eq $to.Kind "taxonomy") (eq $to.Kind "term") }}
      {{- $breadcrumb = $breadcrumb | append $to }}
    {{- end }}
  {{- else }}
    {{- break }}
  {{- end }}
  {{- $to = $to.Parent }}
{{- end }}
{{- $len := len $breadcrumb -}}
{{- $breadcrumbReversed := slice }}
{{- range seq $len }}
  {{- $breadcrumbReversed = $breadcrumbReversed | append (index $breadcrumb (sub $len .)) }}
{{- end }}
{{- $depth := 0 }}
{{- range $i, $e := $breadcrumbReversed }}
  {{- $to := $e }}
  {{- $depth = add $depth 1 }}
  {{- $class := "" }}
  {{- if and (eq $depth 1) site.Params.disableRootBreadcrumb }}
    {{- $class = "a11y-only" }}
  {{- end }}
  {{- $title := partial "title.gotmpl" (dict "page" $to "linkTitle" true) }}
  {{- $url := partial "permalink.gotmpl" (dict "to" $to) }}
  {{- $isPage := eq $url $pageurl }}
  {{- $isLast := eq $url $lasturl }}
  {{- $link := and $url (not $isPage) }}
  {{- if or $.schema (not $class) }}
            <li{{ if $.schema }} itemscope itemtype="https://schema.org/ListItem" itemprop="itemListElement"{{ end }} class="{{ $class | safeHTMLAttr }}">{{ if $link }}<a{{ if $.schema }} itemprop="item"{{ end }} href="{{ $url }}">{{end}}<span{{ if $.schema }} itemprop="name"{{ end }}>{{ $title }}</span>{{ if $link }}</a>{{ end }}{{ if $.schema }}<meta itemprop="position" content="{{ $depth }}">{{ end }}{{ if not $isLast }}{{ (printf "&nbsp;%s&nbsp;" (default ">" .Site.Params.breadcrumbSeparator)) | safeHTML }}{{ end }}</li>
  {{- end }}
{{- end }}