feat: add breadcrumb structured data via BreadcrumbList JSON-LD for non-home pages

This commit is contained in:
George Cushen committed 2025-11-23 02:44:54 +00:00
1 parent 575f85fdde
commit 1bff23752e
2 files changed
+34

No files matched your search

@@ -0,0 +1,30 @@
{{- $page := .page -}}
{{- if not $page.IsHome -}}
{{- $items := slice -}}
{{- $position := 1 -}}
{{- with site.Home -}}
{{- $home_title := .LinkTitle | default site.Title | default "Home" -}}
{{- $items = $items | append (dict "position" $position "name" ($home_title | plainify) "item" .Permalink) -}}
{{- $position = add $position 1 -}}
{{- end -}}
{{- with $page.Ancestors -}}
{{- range .Reverse -}}
{{- if not .IsHome -}}
{{- $items = $items | append (dict "position" $position "name" (.LinkTitle | plainify) "item" .Permalink) -}}
{{- $position = add $position 1 -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $items = $items | append (dict "position" $position "name" ($page.LinkTitle | default $page.Title | plainify) "item" $page.Permalink) -}}
{{- if gt (len $items) 1 -}}
{{- $breadcrumb := dict "@context" "https://schema.org" "@type" "BreadcrumbList" "itemListElement" $items -}}
<script type="application/ld+json">
{{ $breadcrumb | jsonify (dict "indent" " ") | safeJS }}
</script>
{{- end -}}
{{- end -}}
@@ -32,6 +32,10 @@
{{- end }}
{{ if not $page.IsHome }}
{{ partial "jsonld/breadcrumbs.html" (dict "page" $page) }}
{{ end }}
{{/* FAQ content - can appear on any page type including landing pages and homepage */}}
{{ if or ($page.Params.faq_page) ($page.Params.faqs) }}
{{ partial "jsonld/faqpage.html" (dict "page" $page "summary" $summary) }}