diff --git a/layouts/partials/schema.html b/layouts/partials/schema.html index 2f14cc69..6d278272 100644 --- a/layouts/partials/schema.html +++ b/layouts/partials/schema.html @@ -49,22 +49,25 @@ "@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [ - {{- $breadcrumbs := slice -}} + {{- $position := 0 -}} {{- range .Ancestors -}} {{- if not .IsHome -}} - {{- $breadcrumbs = $breadcrumbs | append . -}} + {{- $position = add $position 1 -}} + { + "@type": "ListItem", + "position": {{ $position }}, + "name": "{{ .Title }}", + "item": {{ .Permalink }} + }, {{- end -}} {{- end -}} - {{- $breadcrumbs = $breadcrumbs | append . -}} - - {{- range $index, $element := $breadcrumbs -}} - { - "@type": "ListItem", - "position": {{ add $index 1 }}, - "name": "{{ .Title }}", - "item": {{ .Permalink }}, - }{{ if ne (add $index 1) (len $breadcrumbs) }},{{ end }} - {{- end -}} + {{- $position = add $position 1 -}} + { + "@type": "ListItem", + "position": {{ $position }}, + "name": "{{ .Title }}", + "item": {{ .Permalink }} + } ] }{{ end }}]