mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-05 06:13:14 +00:00
fix: BreadcrumbList structured data to comply with Google Search Console requirements
Add missing @type "ListItem" to breadcrumb items and restructure item field from URL string to object with @id and name properties. Resolves "Invalid object type for field 'itemListElement'" errors reported in Google Search Console. See https://discord.com/channels/722225264733716590/1451194469637427272
This commit is contained in:
1 parent
652923712c
commit
58718ebaec
1 file changed
+6
-3
@@ -6,20 +6,23 @@
|
||||
|
||||
{{- with site.Home -}}
|
||||
{{- $home_title := .LinkTitle | default site.Title | default "Home" -}}
|
||||
{{- $items = $items | append (dict "position" $position "name" ($home_title | plainify) "item" .Permalink) -}}
|
||||
{{- $item := dict "@type" "ListItem" "position" $position "name" ($home_title | plainify) "item" (dict "@id" .Permalink "name" ($home_title | plainify)) -}}
|
||||
{{- $items = $items | append $item -}}
|
||||
{{- $position = add $position 1 -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- with $page.Ancestors -}}
|
||||
{{- range .Reverse -}}
|
||||
{{- if not .IsHome -}}
|
||||
{{- $items = $items | append (dict "position" $position "name" (.LinkTitle | plainify) "item" .Permalink) -}}
|
||||
{{- $item := dict "@type" "ListItem" "position" $position "name" (.LinkTitle | plainify) "item" (dict "@id" .Permalink "name" (.LinkTitle | plainify)) -}}
|
||||
{{- $items = $items | append $item -}}
|
||||
{{- $position = add $position 1 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $items = $items | append (dict "position" $position "name" ($page.LinkTitle | default $page.Title | plainify) "item" $page.Permalink) -}}
|
||||
{{- $item := dict "@type" "ListItem" "position" $position "name" ($page.LinkTitle | default $page.Title | plainify) "item" (dict "@id" $page.Permalink "name" ($page.LinkTitle | default $page.Title | plainify)) -}}
|
||||
{{- $items = $items | append $item -}}
|
||||
|
||||
{{- if gt (len $items) 1 -}}
|
||||
{{- $breadcrumb := dict "@context" "https://schema.org" "@type" "BreadcrumbList" "itemListElement" $items -}}
|
||||
|
||||
Reference in new issue
Block a user