{{- $homeURL := absURL "/" -}}
-{{- $articlesURL := absURL "/articles/" -}}
{{- $homeName := i18n "home" -}}
-{{- $articlesName := i18n "articles" -}}
{{- if eq .Lang "it" -}}
{{- $homeURL = absURL "/it/" -}}
- {{- $articlesURL = absURL "/it/articles/" -}}
{{- end -}}
<script type="application/ld+json">
{
"position": 1,
"name": "{{ $homeName }}",
"item": "{{ $homeURL }}"
- },
- {
+ }
+ {{- $pos := 1 -}}
+ {{- range .Ancestors.Reverse -}}
+ {{- if ne .Kind "home" -}}
+ {{- $pos = add $pos 1 -}}
+ ,{
"@type": "ListItem",
- "position": 2,
- "name": "{{ $articlesName }}",
- "item": "{{ $articlesURL }}"
- },
- {
+ "position": {{ $pos }},
+ "name": "{{ .Title }}",
+ "item": "{{ .Permalink }}"
+ }
+ {{- end -}}
+ {{- end -}}
+ ,{
"@type": "ListItem",
- "position": 3,
+ "position": {{ add $pos 1 }},
"name": "{{ .Title }}"
}
]
{{ $homeLink := "/" }}
-{{ $articlesLink := "/articles/" }}
{{ if eq .Lang "it" }}
{{ $homeLink = "/it/" }}
- {{ $articlesLink = "/it/articles/" }}
{{ end }}
<nav class="breadcrumb mb-6" aria-label="Breadcrumb">
<a href="{{ $homeLink }}">{{ i18n "home" }}</a>
- <span class="breadcrumb-separator">/</span>
- <a href="{{ $articlesLink }}">{{ i18n "articles" }}</a>
+ {{ range .Ancestors.Reverse }}
+ {{ if ne .Kind "home" }}
+ <span class="breadcrumb-separator">/</span>
+ <a href="{{ .RelPermalink }}">{{ .Title }}</a>
+ {{ end }}
+ {{ end }}
<span class="breadcrumb-separator">/</span>
<span>{{ .Title }}</span>
</nav>