Mehr Strukturierte Daten

This commit is contained in:
Patrick Neff 2019-01-15 14:39:30 +01:00
parent 0cc2d87fbe
commit 19f9b66a6e
9 changed files with 81 additions and 2 deletions

View File

@ -1,8 +1,12 @@
{{- partial "schema/site.html" . -}}
{{- if (eq .Kind "page") -}}
{{- if (and (eq .Kind "page") (eq .Type "news")) -}}
{{- partial "schema/post.html" . -}}
{{- end -}}
{{- if (and (eq .Kind "page") (ne .Type "news")) -}}
{{- partial "schema/article.html" . -}}
{{- end -}}
{{- if (eq .Kind "section") -}}
{{- partial "schema/collectionpage.html" . -}}
{{- end -}}
{{- $options := (dict "targetPath" "css/style.css" "outputStyle" "compressed") -}}
{{- if .Site.IsServer -}}

View File

@ -7,6 +7,7 @@
{{- with .ctx.Params.alt -}}
{{- $alt = . -}}
{{- end -}}
{{- $ctx := .ctx -}}
{{ with .image }}
{{ if eq $keep true }}
<img alt="{{ $alt }}"
@ -22,4 +23,5 @@
sizes="(max-width: 500px) 300w, 500w"
src="{{ $imageMd.RelPermalink }}" />
{{ end }}
{{- partial "schema/img.html" (dict "image" . "ctx" $ctx) -}}
{{ end }}

View File

@ -0,0 +1,3 @@
<script type="application/ld+json">
{{- partial "schema/article.jsonld" (dict "post" . "ctx" . "short" false) -}}
</script>

View File

@ -0,0 +1,34 @@
{{- $context := .ctx }}
{{- $post := .post }}
{
"@context": "http://schema.org",
"@type": "Article",
"mainEntityOfPage": {{ partial "schema/site.jsonld" (dict "site" .ctx "ctx" .ctx "short" false) }},
"articleSection": "{{ .post.Section }}",
"name": "{{ .post.Title }}",
"headline": "{{ .post.Title }}",
"description": "{{ with .post.Description }}{{ . }}{{ else }}{{ .Site.Params.description }}{{ end }}",
"inLanguage": "{{ .post.Lang }}",
"author": {{- range (first 1 (where .ctx.Site.Data.kontakt.kontakt ".address.addressLocality" "Niederkassel")) -}}
{{ partial "schema/organization.jsonld" (dict "org" . "ctx" $context "short" true) }}
{{- end -}},
"creator": {{- range (first 1 (where .ctx.Site.Data.kontakt.kontakt ".address.addressLocality" "Niederkassel")) -}}
{{ partial "schema/organization.jsonld" (dict "org" . "ctx" $context "short" true) }}
{{- end -}},
"publisher": {{- range (first 1 (where .ctx.Site.Data.kontakt.kontakt ".address.addressLocality" "Niederkassel")) -}}
{{ partial "schema/organization.jsonld" (dict "org" . "ctx" $context "short" true) }}
{{- end -}},
"copyrightHolder":
{{- range (first 1 (where .ctx.Site.Data.kontakt.kontakt ".address.addressLocality" "Niederkassel")) -}}
{{ partial "schema/organization.jsonld" (dict "org" . "ctx" $context "short" true) }}
{{- end -}},
"copyrightYear": "{{ .post.Date.Format "2006" }}",
"datePublished": "{{ .post.PublishDate | safeHTML }}",
"dateModified": "{{ .post.Lastmod | safeHTML }}",
"url": "{{ .post.Permalink }}",
"wordCount": "{{ .post.WordCount }}",
"keywords": "{{ with .post.Keywords }}{{ delimit . ", " }}{{ end }}",
{{ $imageURL := path.Join .post.RelPermalink "bilder/" .post.Params.featuredImage }}
"image": {{ partial "schema/image.jsonld" (dict "url" $imageURL "ctx" .ctx) }},
"articleBody": {{ .ctx.Content | jsonify }}
}

View File

@ -0,0 +1,3 @@
<script type="application/ld+json">
{{- partial "schema/collectionpage.jsonld" (dict "list" . "ctx" .) -}}
</script>

View File

@ -0,0 +1,21 @@
{{- $context := .ctx -}}
{{- $list := .list -}}
{
"@context":"http://schema.org/",
"@type":"CollectionPage",
"name":"{{ $list.Title }}",
"headline":"{{ $list.Title }}",
"mainEntityOfPage": {{ partial "schema/site.jsonld" (dict "site" .ctx "ctx" .ctx "short" false) }},
"author": {{- range (first 1 (where .ctx.Site.Data.kontakt.kontakt ".address.addressLocality" "Niederkassel")) -}}
{{ partial "schema/organization.jsonld" (dict "org" . "ctx" $context "short" true) }}
{{- end -}},
{{- with $list.Description }}
"description": "{{ . }}",
{{- end -}}
"hasPart": [
{{- range $idx, $page := $list.Pages -}}
{{- if ne $idx 0 -}},{{- end -}}
{{ partial "schema/post.jsonld" (dict "post" $page "ctx" $context)}}
{{- end -}}
]
}

View File

@ -0,0 +1,3 @@
<script type="application/ld+json">
{{- partial "schema/img.jsonld" (dict "image" .image "ctx" .ctx) -}}
</script>

View File

@ -0,0 +1,9 @@
{{- $context := .ctx -}}
{{- $site := .site -}}
{
"@context": "http://schema.org",
"@type": "ImageObject",
"@id": {{ .image.Permalink | jsonify }},
"url": {{ .image.Permalink | jsonify }},
"caption": {{ .image.Params.alt | jsonify }}
}

View File

@ -3,7 +3,7 @@
{
"@context": "http://schema.org",
"@type": "BlogPosting",
"mainEntityOfPage": {{ partial "schema/site.jsonld" (dict "site" .ctx "ctx" .ctx "short" true) }},
"mainEntityOfPage": {{ partial "schema/site.jsonld" (dict "site" .ctx "ctx" .ctx "short" false) }},
"articleSection": "{{ .post.Section }}",
"name": "{{ .post.Title }}",
"headline": "{{ .post.Title }}",