* Add schema.org BreadcrumbList to JSON+LD This implementation depends on .Page.Ancestors, which requires Hugo version v0.109.0. Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca> * Fix extraneous comma in schema For blog posts we ended up with an extraneous comma due to it being outside the condition for the breadcrumb JSON+LD. Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca> * Pretty print breadcrumb JSON+LD for schema Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca> * Make breadcrumbs opt-in on non-blogSections Sections except blogSections (which is a configurable set which is defaulted to sections 'blog' and 'post'), may be part of `breadcrumbSections`. For the breadcrumb Sections, the section and any pages under it will have the `breadcrumb` attribute (of type `BreadcrumbList`) added to the JSON+LD for their schema.org structured data. Update documentation of `params` for example `config.yaml` in README. Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca> --------- Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
61 lines
1.8 KiB
HTML
61 lines
1.8 KiB
HTML
<script type="application/ld+json">
|
|
{{- $blogSections := site.Params.blogSections | default (slice "blog" "post") }}
|
|
{{- $breadcrumbSections := site.Params.breadcrumbSections | default (slice) }}
|
|
{
|
|
"@context": "https://schema.org",
|
|
{{ if .IsPage -}}
|
|
"@type": {{ if in $blogSections .Section -}}
|
|
"BlogPosting",
|
|
{{- else -}}
|
|
"WebPage",
|
|
{{- if in $breadcrumbSections .Section }}
|
|
"breadcrumb": {{ safeJS (partial "meta_breadcrumb_json_ld.html" .) }},
|
|
{{- end -}}
|
|
{{- end }}
|
|
"headline": {{ .Title }},
|
|
"datePublished": {{ .Date.Format "2006-01-02T15:04:05Z07:00" }},
|
|
"dateModified": {{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }},
|
|
"url" : {{ .Permalink }},
|
|
{{ with (.Description | default (replaceRE "\n" " " (.Plain | truncate 170))) -}}
|
|
"description": {{ . }},
|
|
{{ end -}}
|
|
{{ with .Params.tags -}}
|
|
"keywords": {{ . }},
|
|
{{ end -}}
|
|
{{ else -}}
|
|
"@type": "WebPage",
|
|
{{- if in $breadcrumbSections .Section }}
|
|
"breadcrumb": {{ safeJS (partial "meta_breadcrumb_json_ld.html" .) }},
|
|
{{- end }}
|
|
"url" : {{ .Permalink }},
|
|
"name": {{ .Title }},
|
|
{{ with $.Param "description" -}}
|
|
"description": {{ . }},
|
|
{{ end -}}
|
|
{{ end -}}
|
|
{{ with $.Param "image" -}}
|
|
"image" : {{ . | absURL }},
|
|
{{ end -}}
|
|
{{ with $.Param "author" -}}
|
|
"author": {
|
|
"@type": "Person",
|
|
"name": {{ . }}
|
|
},
|
|
{{ end -}}
|
|
"mainEntityOfPage": {
|
|
"@type": "WebPage",
|
|
"@id": {{ site.BaseURL }}
|
|
},
|
|
"publisher": {
|
|
"@type": "Organization",
|
|
"name": {{ site.Title }},
|
|
{{ with $.Param "icon" -}}
|
|
"logo" : {
|
|
"@type": "ImageObject",
|
|
"url": {{ . | absURL }}
|
|
},
|
|
{{ end -}}
|
|
"url": {{ site.BaseURL }}
|
|
}
|
|
}
|
|
</script>
|