fix ld+json formatting;

This commit is contained in:
wgroeneveld 2020-06-09 13:31:33 +02:00
parent 0364e4b1bc
commit 684dab57ec
1 changed files with 20 additions and 9 deletions

View File

@ -40,29 +40,37 @@
<!-- end og --> <!-- end og -->
<!-- structured data --> <!-- structured data -->
{{ $ISO8601 := "2006-01-02T15:04:05-07:00" }}
<script type="application/ld+json"> <script type="application/ld+json">
{ {
"@context" : "http://schema.org", "@context" : "http://schema.org",
"@type" : "BlogPosting", "@type" : "BlogPosting",
"mainEntityOfPage": { "mainEntityOfPage": {
"@type": "WebPage", "@type": "WebPage",
"@id": "{{ .Site.BaseURL }}" "@id": {{ .Site.BaseURL }}
}, },
"articleSection" : "{{ .Section }}", "articleSection" : "{{ .Section }}",
"name" : "{{ .Title }}", "name" : "{{ .Title }}",
"headline" : "{{ $isHomePage := eq .Title .Site.Title }}{{ .Title }}{{ if eq $isHomePage false }} - {{ .Site.Title }}{{ end }}", "headline" : "{{ $isHomePage := eq .Title .Site.Title }}{{ .Title }}{{ if eq $isHomePage false }} - {{ .Site.Title }}{{ end }}",
"description" : "{{ if .Description }}{{ .Description }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ end }}{{ end }}", "description" : {{ if .Description }}{{ .Description }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ end }}{{ end }},
"inLanguage" : "{{ .Site.LanguageCode }}", "inLanguage" : "{{ .Site.LanguageCode }}",
{{ if .Params.image }} {{ if .Params.image }}
"image": "{{.Site.BaseURL}}{{ .Params.image }}", "image": {{ .Params.image | absURL }},
{{ else }}
"image": "{{.Site.BaseURL}}img/logo.png",
{{ end }} {{ end }}
"author" : { "author" : {
"@type": "Person", "@type": "Person",
"name": "{{ .Site.Author.name }}" "name": "{{ .Site.Author.name }}"
}, },
"creator" : {
"@type": "Person",
"name": "{{ .Site.Author.name }}"
},
"publisher": { "publisher": {
"@type": "Organization", "@type": "Organization",
"name": "Brain Baking", "name": "Brain Baking",
"url": {{ .Site.BaseURL }},
"logo": { "logo": {
"@type": "ImageObject", "@type": "ImageObject",
"url": "https://brainbaking.com/img/avatar-icon.png", "url": "https://brainbaking.com/img/avatar-icon.png",
@ -73,14 +81,17 @@
"accountablePerson" : "{{ .Site.Author.name }}", "accountablePerson" : "{{ .Site.Author.name }}",
"copyrightHolder" : "{{ .Site.Author.name }}", "copyrightHolder" : "{{ .Site.Author.name }}",
"copyrightYear" : "{{ .Date.Format "2006" }}", "copyrightYear" : "{{ .Date.Format "2006" }}",
"datePublished": "{{ .Date }}", "dateCreated": {{ .Date.Format $ISO8601 }},
"dateModified" : "{{ .Lastmod }}", "datePublished": {{ .PublishDate.Format $ISO8601 }},
"url" : "{{ .Permalink }}", "dateModified": {{ .Lastmod.Format $ISO8601 }},
"url" : {{ .Permalink }},
"wordCount" : "{{ .WordCount }}", "wordCount" : "{{ .WordCount }}",
{{ if .Keywords }} {{ if .Keywords }}
"keywords" : [ {{ range .Keywords }}"{{ . }}",{{ end }}"{{ .Title }}" ] "keywords" : [ {{ range .Keywords }}"{{ . }}",{{ end }}"{{ .Title }}" ],
"genre" : [ {{ range .Keywords }}"{{ . }}",{{ end }}"{{ .Title }}" ]
{{ else if .Params.tags }} {{ else if .Params.tags }}
"keywords" : [ {{ if isset .Params "tags" }}{{ range .Params.tags }}"{{ . }}",{{ end }}{{ end }}"{{ .Title }}" ] "keywords" : [ {{ if isset .Params "tags" }}{{ range .Params.tags }}"{{ . }}",{{ end }}{{ end }}"{{ .Title }}" ],
"genre" : [ {{ if isset .Params "tags" }}{{ range .Params.tags }}"{{ . }}",{{ end }}{{ end }}"{{ .Title }}" ]
{{ else }} {{ else }}
"keywords": [ "{{ .Title }}" ] "keywords": [ "{{ .Title }}" ]
{{ end }} {{ end }}