1
0
mirror of https://github.com/alanorth/hugo-theme-bootstrap4-blog.git synced 2024-12-19 00:52:19 +01:00

layouts: Quote some parameters in JSON LD

Current Hugo 0.19-DEV doesn't quote these anymore, so we need to
add quotes manually. I'm not sure if this is a design decision or
not on Hugo's part.
This commit is contained in:
Alan Orth 2017-02-21 08:17:19 +02:00
parent 0e5937b1b7
commit 4d7a544dac
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
2 changed files with 15 additions and 15 deletions

View File

@ -4,24 +4,24 @@
"@context": "http://schema.org",
"@type": "Blog",
{{/* Google recommends the headline be no more than 110 characters */}}
"headline": {{ substr .Site.Title 0 110 }},
"url" : {{ printf "%s" .Permalink }},
"headline": "{{ substr .Site.Title 0 110 }}",
"url" : "{{ printf "%s" .Permalink }}",
"author": {
"@type": "Person",
"name": {{ .Site.Params.author }}
"name": "{{ .Site.Params.author }}"
},
{{ $ISO8601 := "2006-01-02T15:04:05-07:00" }}
{{ if not .Date.IsZero }}
"dateModified": {{ .Date.Format $ISO8601 }},
"dateModified": "{{ .Date.Format $ISO8601 }}",
{{ end }}
{{ with .Site.Social.GooglePlus }}
"publisher": {{ printf "%s" . }},
"publisher": "{{ printf "%s" . }}",
{{ end }}
{{/* all of the site's categories/tags, from Hugo's tpl/template_embedded.go */}}
"keywords": "{{ range $plural, $terms := .Site.Taxonomies }}{{ range $term, $val := $terms }}{{ printf "%s," $term }}{{ end }}{{ end }}"
{{ with .Site.Params.description }}
,
"description": {{- . -}}
"description": "{{- . -}}"
{{ end }}
}
</script>

View File

@ -6,30 +6,30 @@
"@context": "http://schema.org",
"@type": "BlogPosting",
{{/* Google recommends the headline be no more than 110 characters */}}
"headline": {{ substr .Title 0 110 }},
"headline": "{{ substr .Title 0 110 }}",
{{- with .Params.images -}}{{ range first 1 . }}
"image": {
"@type": "ImageObject",
"url": {{ . | absURL }}
"url": "{{ . | absURL }}"
},
{{- end -}}{{ end }}
"url": {{ printf "%s" .Permalink }},
"url": "{{ printf "%s" .Permalink }}",
"wordCount": "{{ .WordCount }}",
{{ $ISO8601 := "2006-01-02T15:04:05-07:00" }}
{{ if not .PublishDate.IsZero }}
"datePublished": {{ .PublishDate.Format $ISO8601 }},
"datePublished": "{{ .PublishDate.Format $ISO8601 }}",
{{ else }}
"datePublished": {{ .Date.Format $ISO8601 }},
"datePublished": "{{ .Date.Format $ISO8601 }}",
{{ end }}
{{ if not .Lastmod.IsZero }}
"dateModified": {{ .Lastmod.Format $ISO8601 }},
"dateModified": "{{ .Lastmod.Format $ISO8601 }}",
{{ end }}
{{ with .Site.Social.GooglePlus }}
"publisher": {{ printf "%s" . }},
"publisher": "{{ printf "%s" . }}",
{{ end }}
"author": {
"@type": "Person",
"name": {{ .Params.author | default .Site.Params.author }}
"name": "{{ .Params.author | default .Site.Params.author }}"
}
{{ if or (.Params.categories) (.Params.tags) }}
,
@ -38,7 +38,7 @@
{{- with .Params.description -}}
,
"description": {{ . }}
"description": "{{ . }}"
{{ end }}
}
</script>