summaryrefslogtreecommitdiffstats
path: root/layouts/partials/breadcrumb-jsonld.html
blob: 95b5e69db43bfa59b01bc3e18be50f061f558cf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{{- $homeURL := absURL "/" -}}
{{- $homeName := i18n "home" -}}
{{- if eq .Lang "it" -}}
  {{- $homeURL = absURL "/it/" -}}
{{- end -}}
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "BreadcrumbList",
  "itemListElement": [
    {
      "@type": "ListItem",
      "position": 1,
      "name": "{{ $homeName }}",
      "item": "{{ $homeURL }}"
    }
    {{- $pos := 1 -}}
    {{- range .Ancestors.Reverse -}}
      {{- if ne .Kind "home" -}}
        {{- $pos = add $pos 1 -}}
    ,{
      "@type": "ListItem",
      "position": {{ $pos }},
      "name": "{{ .Title }}",
      "item": "{{ .Permalink }}"
    }
      {{- end -}}
    {{- end -}}
    ,{
      "@type": "ListItem",
      "position": {{ add $pos 1 }},
      "name": "{{ .Title }}"
    }
  ]
}
</script>