congo/layouts/partials/schema.html

41 lines
1.7 KiB
HTML

{{ if .IsHome -}}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebSite",
"name": "{{ .Site.Title | safeJS }}",
"url": "{{ .Site.BaseURL | safeURL }}",
"description": "{{ .Site.Params.description | safeJS }}"
}
</script>
{{ else if .IsPage }}
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BlogPosting",
"articleSection": "{{ (site.GetPage .Section).Title }}",
"name": "{{ .Title | safeJS }}",
"headline": "{{ .Title | safeJS }}",
"description": "{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}",
{{ with .Site.LanguageCode }}"inLanguage": {{ . }},{{ end }}
"author" : {
"@type": "Person",
"name": "{{ .Site.Author.name | safeJS }}"
},
"creator" : {
"@type": "Person",
"name": "{{ .Site.Author.name | safeJS }}"
},
"copyrightHolder": "{{ .Site.Author.name | safeJS }}",
{{ with .PublishDate }}"copyrightYear": "{{ .Format "2006" }}",{{ end }}
{{ with .PublishDate }}"dateCreated": "{{ .Format $iso8601 }}",{{ end }}
{{ with .PublishDate }}"datePublished": "{{ .Format $iso8601 }}",{{ end }}
{{ with .Lastmod }}"dateModified": "{{ .Format $iso8601 }}",{{ end }}
"url" : "{{ .Permalink }}",
"wordCount": "{{ .WordCount }}",
"keywords": [{{ if .IsPage}}{{ range $index, $tag := .Params.tags }}{{ $tag }},{{ end }}{{ else }}{{ range $plural, $terms := .Site.Taxonomies }}{{ range $term, $val := $terms }}{{ printf "%s," $term }}{{ end }}{{ end }}{{ end }}]
}
</script>
{{ end }}