mirror of
https://github.com/alanorth/hugo-theme-bootstrap4-blog.git
synced 2024-11-17 17:57:04 +01:00
Clean up empty whitespace in JSON-LD
Use secret formatting feature of Go templates, adding - to blocks to clear whitespace around the tags.
This commit is contained in:
parent
d554b6bead
commit
e2ccfe8bf3
@ -3,26 +3,26 @@
|
|||||||
{
|
{
|
||||||
"@context": "http://schema.org",
|
"@context": "http://schema.org",
|
||||||
"@type": "Blog",
|
"@type": "Blog",
|
||||||
{{/* Google recommends the headline be no more than 110 characters */}}
|
{{- /* Google recommends the headline be no more than 110 characters */}}
|
||||||
"headline": "{{ substr .Site.Title 0 110 }}",
|
"headline": "{{ substr .Site.Title 0 110 }}",
|
||||||
"url" : "{{ printf "%s" .Permalink }}",
|
"url" : "{{ printf "%s" .Permalink }}",
|
||||||
"author": {
|
"author": {
|
||||||
"@type": "Person",
|
"@type": "Person",
|
||||||
"name": "{{ .Site.Params.author }}"
|
"name": "{{ .Site.Params.author }}"
|
||||||
},
|
},
|
||||||
{{ $ISO8601 := "2006-01-02T15:04:05-07:00" }}
|
{{- $ISO8601 := "2006-01-02T15:04:05-07:00" }}
|
||||||
{{ if not .Date.IsZero }}
|
{{- if not .Date.IsZero }}
|
||||||
"dateModified": "{{ .Date.Format $ISO8601 }}",
|
"dateModified": "{{ .Date.Format $ISO8601 }}",
|
||||||
{{ end }}
|
{{- end }}
|
||||||
{{ with .Site.Social.GooglePlus }}
|
{{- with .Site.Social.GooglePlus }}
|
||||||
"publisher": "{{ printf "%s" . }}",
|
"publisher": "{{ printf "%s" . }}",
|
||||||
{{ end }}
|
{{- end }}
|
||||||
{{/* all of the site's categories/tags, from Hugo's tpl/template_embedded.go */}}
|
{{- /* 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 }}"
|
"keywords": "{{ range $plural, $terms := .Site.Taxonomies }}{{ range $term, $val := $terms }}{{ printf "%s," $term }}{{ end }}{{ end }}"
|
||||||
{{ with .Site.Params.description }}
|
{{- with .Site.Params.description -}}
|
||||||
,
|
,
|
||||||
"description": "{{- . -}}"
|
"description": "{{- . -}}"
|
||||||
{{ end }}
|
{{- end }}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
{
|
{
|
||||||
"@context": "http://schema.org",
|
"@context": "http://schema.org",
|
||||||
"@type": "BlogPosting",
|
"@type": "BlogPosting",
|
||||||
{{/* Google recommends the headline be no more than 110 characters */}}
|
{{- /* 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 . }}
|
{{- with .Params.images -}}{{ range first 1 . }}
|
||||||
"image": {
|
"image": {
|
||||||
@ -17,37 +17,37 @@
|
|||||||
,
|
,
|
||||||
"height": "{{ .Height }}",
|
"height": "{{ .Height }}",
|
||||||
"width": "{{ .Width }}"
|
"width": "{{ .Width }}"
|
||||||
{{ end }}
|
{{- end -}}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
},
|
},
|
||||||
{{- end -}}{{ end }}
|
{{- end -}}{{ end }}
|
||||||
"url": "{{ printf "%s" .Permalink }}",
|
"url": "{{ printf "%s" .Permalink }}",
|
||||||
"wordCount": "{{ .WordCount }}",
|
"wordCount": "{{ .WordCount }}",
|
||||||
{{ $ISO8601 := "2006-01-02T15:04:05-07:00" }}
|
{{- $ISO8601 := "2006-01-02T15:04:05-07:00" }}
|
||||||
{{ if not .PublishDate.IsZero }}
|
{{- if not .PublishDate.IsZero }}
|
||||||
"datePublished": "{{ .PublishDate.Format $ISO8601 }}",
|
"datePublished": "{{ .PublishDate.Format $ISO8601 }}",
|
||||||
{{ else }}
|
{{- else }}
|
||||||
"datePublished": "{{ .Date.Format $ISO8601 }}",
|
"datePublished": "{{ .Date.Format $ISO8601 }}",
|
||||||
{{ end }}
|
{{- end }}
|
||||||
{{ if not .Lastmod.IsZero }}
|
{{- if not .Lastmod.IsZero }}
|
||||||
"dateModified": "{{ .Lastmod.Format $ISO8601 }}",
|
"dateModified": "{{ .Lastmod.Format $ISO8601 }}",
|
||||||
{{ end }}
|
{{- end }}
|
||||||
{{ with .Site.Social.GooglePlus }}
|
{{- with .Site.Social.GooglePlus }}
|
||||||
"publisher": "{{ printf "%s" . }}",
|
"publisher": "{{ printf "%s" . }}",
|
||||||
{{ end }}
|
{{- end }}
|
||||||
"author": {
|
"author": {
|
||||||
"@type": "Person",
|
"@type": "Person",
|
||||||
"name": "{{ .Params.author | default .Site.Params.author }}"
|
"name": "{{ .Params.author | default .Site.Params.author }}"
|
||||||
}
|
}
|
||||||
{{ if or (.Params.categories) (.Params.tags) }}
|
{{- if or (.Params.categories) (.Params.tags) -}}
|
||||||
,
|
,
|
||||||
"keywords": "{{ with .Params.categories }}{{ range $i, $e := . }}{{ if $i }},{{ end }}{{ $e }}{{ end }},{{ end }}{{ with .Params.tags }}{{ range $i, $e := . }}{{ if $i }},{{ end }}{{ $e }}{{ end }}{{ end }}"
|
"keywords": "{{ with .Params.categories }}{{ range $i, $e := . }}{{ if $i }},{{ end }}{{ $e }}{{ end }},{{ end }}{{ with .Params.tags }}{{ range $i, $e := . }}{{ if $i }},{{ end }}{{ $e }}{{ end }}{{ end }}"
|
||||||
{{ end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- with .Params.description -}}
|
{{- with .Params.description -}}
|
||||||
,
|
,
|
||||||
"description": "{{ . }}"
|
"description": "{{ . }}"
|
||||||
{{ end }}
|
{{- end }}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user