summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--layouts/partials/templates/schema_json.html43
1 files changed, 42 insertions, 1 deletions
diff --git a/layouts/partials/templates/schema_json.html b/layouts/partials/templates/schema_json.html
index 5cf407e..6e71082 100644
--- a/layouts/partials/templates/schema_json.html
+++ b/layouts/partials/templates/schema_json.html
@@ -16,7 +16,46 @@
]
}
</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">
{
"@context": "https://schema.org",
@@ -75,4 +114,6 @@
}
}
</script>
+{{ end }}{{/* .IsPage end */}}
+
{{ end }}