mirror of
https://github.com/Wonderfall/hugo-WonderMod.git
synced 2024-11-22 02:21:37 +01:00
add structured data for breadcrumb nav
https://developers.google.com/search/docs/data-types/breadcrumb
This commit is contained in:
parent
a21094f4a0
commit
17d48ce9bb
@ -16,7 +16,46 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{{- else if .IsPage }}
|
{{- else if (or .IsPage .IsSection) }}
|
||||||
|
{{/* BreadcrumbList */}}
|
||||||
|
{{- $url := replace .Parent.Permalink ( printf "%s" .Site.BaseURL) "" }}
|
||||||
|
{{- $lang_url := replace $url ( printf "%s" .Lang) "" }}
|
||||||
|
{{- $bc_list := (split $lang_url "/")}}
|
||||||
|
|
||||||
|
{{- $scratch := newScratch }}
|
||||||
|
<script type="application/ld+json">
|
||||||
|
{
|
||||||
|
"@context": "https://schema.org",
|
||||||
|
"@type": "BreadcrumbList",
|
||||||
|
"itemListElement": [
|
||||||
|
{{- range $index, $element := $bc_list }}
|
||||||
|
|
||||||
|
{{- $scratch.Add "path" (printf "%s/" $element ) | safeJS }}
|
||||||
|
{{- $bc_pg := $.Site.GetPage ($scratch.Get "path") -}}
|
||||||
|
|
||||||
|
{{- if (and ($bc_pg) (gt (len . ) 0))}}
|
||||||
|
{{- if (and $index)}}, {{end }}
|
||||||
|
{
|
||||||
|
"@type": "ListItem",
|
||||||
|
"position": {{ add 1 $index }},
|
||||||
|
"name": {{ $bc_pg.Name }},
|
||||||
|
"item": {{ $bc_pg.Permalink | safeHTML }}
|
||||||
|
}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- end }}
|
||||||
|
{{- /* self-page addition */ -}}
|
||||||
|
{{- if $bc_list }}, {{end }}
|
||||||
|
{
|
||||||
|
"@type": "ListItem",
|
||||||
|
"position": {{len $bc_list}},
|
||||||
|
"name": {{ .Name }},
|
||||||
|
"item": {{ .Permalink | safeHTML }}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{{- if .IsPage }}
|
||||||
<script type="application/ld+json">
|
<script type="application/ld+json">
|
||||||
{
|
{
|
||||||
"@context": "https://schema.org",
|
"@context": "https://schema.org",
|
||||||
@ -75,4 +114,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
{{ end }}{{/* .IsPage end */}}
|
||||||
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
Loading…
Reference in New Issue
Block a user