From 1bff23752e078f9a6d2028e2e650037ce5996ecd Mon Sep 17 00:00:00 2001 From: George Cushen Date: Sun, 23 Nov 2025 02:44:54 +0000 Subject: [PATCH] feat: add breadcrumb structured data via BreadcrumbList JSON-LD for non-home pages --- .../layouts/_partials/jsonld/breadcrumbs.html | 30 +++++++++++++++++++ .../layouts/_partials/jsonld/main.html | 4 +++ 2 files changed, 34 insertions(+) create mode 100644 modules/blox-tailwind/layouts/_partials/jsonld/breadcrumbs.html diff --git a/modules/blox-tailwind/layouts/_partials/jsonld/breadcrumbs.html b/modules/blox-tailwind/layouts/_partials/jsonld/breadcrumbs.html new file mode 100644 index 00000000..b269eee7 --- /dev/null +++ b/modules/blox-tailwind/layouts/_partials/jsonld/breadcrumbs.html @@ -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 -}} + + {{- end -}} +{{- end -}} diff --git a/modules/blox-tailwind/layouts/_partials/jsonld/main.html b/modules/blox-tailwind/layouts/_partials/jsonld/main.html index 0292e021..e23fab82 100644 --- a/modules/blox-tailwind/layouts/_partials/jsonld/main.html +++ b/modules/blox-tailwind/layouts/_partials/jsonld/main.html @@ -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) }}