From 4d7a544dacfe037f5f01a1bc84fb2cbf7cc0cb23 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Tue, 21 Feb 2017 08:17:19 +0200 Subject: [PATCH] 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. --- layouts/_default/list.html | 12 ++++++------ layouts/_default/single.html | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/layouts/_default/list.html b/layouts/_default/list.html index dacefe8..689afc3 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -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 }} } diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 0543fc0..de9a14e 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -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 }} }