layouts: Fix more structured data escaping issues

I think we actually only need to quote string literals. Otherwise,
it seems that Hugo automatically adds quoting for us, and doesn't
use funny escaping of URLs, special characters, etc.
This commit is contained in:
Alan Orth 2020-03-19 15:45:31 +02:00
parent 9e0b00038a
commit 85abd20ba7
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
2 changed files with 7 additions and 7 deletions

View File

@ -4,11 +4,11 @@
"@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 }}

View File

@ -6,11 +6,11 @@
"@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 }}
{{- /* Don't try to get imageConfig if image param is not local */ -}}
{{- if not (or (hasPrefix . "http://") (hasPrefix . "https://")) -}}
{{- with (imageConfig (printf "/static/%s" .)) -}}
@ -21,7 +21,7 @@
{{ end }}
},
{{- end -}}{{ end }}
"url": "{{ printf "%s" .Permalink }}",
"url": {{ printf "%s" .Permalink }},
"wordCount": "{{ .WordCount }}",
{{- $ISO8601 := "2006-01-02T15:04:05-07:00" }}
{{- if not .PublishDate.IsZero }}
@ -34,7 +34,7 @@
{{- end }}
"author": {
"@type": "Person",
"name": "{{ .Params.author | default .Site.Params.author }}"
"name": {{ .Params.author | default .Site.Params.author }}
}
{{- if or (.Params.keywords) (or (.Params.categories) (.Params.tags)) -}}
,