portails/layouts/partials/head/structured-data.html

109 lines
3.5 KiB
HTML
Raw Normal View History

2020-04-15 15:48:16 +02:00
{{ if .IsHome -}}
{{ if eq .Site.Params.schemaType "Organization" -}}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Organization",
2021-04-02 19:45:05 +02:00
"url": "{{ "/" | relURL }}",
2020-04-15 15:48:16 +02:00
"name": "{{ .Site.Params.title }}",
2021-04-02 19:45:05 +02:00
"logo": "{{ "/" | relURL }}{{ .Site.Params.schemaLogo }}",
2020-04-15 15:48:16 +02:00
"sameAs": [
"{{ .Site.Params.schemaTwitter | safeURL }}",
2020-11-04 08:26:58 +01:00
"{{ .Site.Params.schemaLinkedIn | safeURL }}",
"{{ .Site.Params.schemaGitHub | safeURL }}"
2020-04-15 15:48:16 +02:00
]
}
</script>
{{ end -}}
{{ if eq .Site.Params.schemaType "Person" -}}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Person",
2021-04-02 19:45:05 +02:00
"url": "{{ "/" | relURL }}",
2020-04-15 15:48:16 +02:00
"name": "{{ .Site.Params.title }}",
"sameAs": [
"{{ .Site.Params.schemaTwitter | safeURL }}",
2020-11-04 08:26:58 +01:00
"{{ .Site.Params.schemaLinkedIn | safeURL }}",
"{{ .Site.Params.schemaGitHub | safeURL }}"
2020-04-15 15:48:16 +02:00
]
}
</script>
{{ end -}}
{{ if .Site.Params.siteLinksSearchBox -}}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebSite",
2021-04-02 19:45:05 +02:00
"url": "{{ "/" | relURL }}",
2020-04-15 15:48:16 +02:00
"potentialAction": {
"@type": "SearchAction",
2021-04-02 19:45:05 +02:00
"target": "{{ "/" | relURL }}?q={search_term_string}",
2020-04-15 15:48:16 +02:00
"query-input": "required name=search_term_string"
}
}
</script>
{{ end -}}
{{ end -}}
{{ if .IsPage -}}
{{ if eq .Section .Site.Params.schemaSection -}}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Article",
"mainEntityOfPage": {
"@type": "WebPage",
2021-04-02 19:45:05 +02:00
"@id": "{{ .RelPermalink }}"
2020-04-15 15:48:16 +02:00
},
"headline": "{{ .Title }}",
2021-04-02 19:45:05 +02:00
"image": [{{ range $i, $e := .Params.images }}{{ if $i }}, {{ end }}{{ printf "%s%s" $.RelPermalink $e }}{{ end }}],
2020-04-15 15:48:16 +02:00
"datePublished": "{{ .PublishDate.Format "2006-01-02T15:04:05CET" }}",
"dateModified": "{{ .Lastmod.Format "2006-01-02T15:04:05CET" }}",
"author": {
"@type": "{{ .Site.Params.schemaType }}",
"name": "{{ .Site.Params.title }}"
},
"publisher": {
"@type": "{{ .Site.Params.schemaType }}",
"name": "{{ .Site.Params.title }}",
{{ if eq .Site.Params.schemaType "Organization" -}}
"logo": {
"@type": "ImageObject",
2021-04-02 19:45:05 +02:00
"url": "{{ "/" | relURL }}{{ .Site.Params.schemaLogo }}"
2020-04-15 15:48:16 +02:00
}
{{ end -}}
},
"description": "{{ .Description }}"
}
</script>
{{ end -}}
{{ end -}}
2020-11-04 08:26:58 +01:00
{{ $dot := . -}}
{{ $dot.Scratch.Set "path" "" -}}
{{ $dot.Scratch.Set "breadcrumb" slice -}}
2021-04-02 19:45:05 +02:00
{{ $url := replace .RelPermalink ( printf "%s" .Site.BaseURL) "" -}}
2020-04-15 15:48:16 +02:00
{{ $.Scratch.Add "path" .Site.BaseURL -}}
{{ $.Scratch.Add "breadcrumb" (slice (dict "url" .Site.BaseURL "name" "home" "position" 1 )) -}}
2020-11-04 08:26:58 +01:00
{{ range $index, $element := split $url "/" -}}
{{ $dot.Scratch.Add "path" $element -}}
{{ $.Scratch.Add "path" "/" -}}
2020-04-15 15:48:16 +02:00
{{ if ne $element "" -}}
2020-11-04 08:26:58 +01:00
{{ $.Scratch.Add "breadcrumb" (slice (dict "url" ($.Scratch.Get "path") "name" . "position" (add $index 2))) -}}
{{ end -}}
2020-04-15 15:48:16 +02:00
{{ end -}}
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [{{ range $.Scratch.Get "breadcrumb" }}{{ if ne .position 1 }},{{ end }}{
"@type": "ListItem",
"position": {{ .position }},
2020-11-04 08:26:58 +01:00
"name": "{{ .name | humanize | title }}",
"item": "{{ .url }}"
2020-04-15 15:48:16 +02:00
}{{ end }}]
}
2020-11-04 08:26:58 +01:00
</script>