hugo-geekblog/layouts/partials/head/schema.html

70 lines
2.6 KiB
HTML
Raw Normal View History

2020-07-24 20:25:04 +00:00
{{ if .IsHome -}}
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
{{ with .Site.Params.GeekblogAuthor -}}
{{ with index $.Site.Data.authors . }}"author": "{{ .name }}",{{ end }}
{{- end }}
"name": "{{ .Site.Title }}",
"url": "{{ .Site.BaseURL }}",
"description": "{{ .Site.Params.description }}",
"thumbnailUrl": "{{ (default "brand.svg" .Site.Params.logo) | absURL }}"{{ with .Site.Params.GeekblogContentLicense }},
"license": "{{ .name }}"{{ end }}
}
</script>
{{ else if .IsPage }}
{{ $authors := default (slice .Site.Params.GeekblogAuthor) .Params.authors }}
{{ $ac := 0 }}
{{ $ac_max := default 0 (len $authors) }}
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BlogPosting",
"articleSection": "{{ .Section }}",
"name": "{{ .Title | safeJS }}",
"headline": "{{ .Title | safeJS }}",
"alternativeHeadline": "{{ .Params.lead }}",
"description": "{{ if .Description }}{{ .Description | safeJS }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ end }}{{ end }}",
"inLanguage": {{ .Site.Language.Lang }},
"isFamilyFriendly": "true",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "{{ .Permalink }}"
},
"author" : [
{{- with $authors -}}
{{- range sort . }}
{{- $ac = (add $ac 1) }}
{{- $author := index $.Site.Data.authors . }}
{
"@type": "Person",
"name": "{{ $author.name }}"
}{{ if lt $ac $ac_max }},{{ end }}
{{- end -}}
{{- end }}
],
"copyrightHolder" : "{{ .Site.Title }}",
"copyrightYear" : "{{ .Date.Format "2006" }}",
"dateCreated": "{{ .Date.Format "2006-01-02T15:04:05.00Z" | safeJS }}",
"datePublished": "{{ .PublishDate.Format "2006-01-02T15:04:05.00Z" | safeJS }}",
"dateModified": "{{ .Lastmod.Format "2006-01-02T15:04:05.00Z" | safeJS }}",
"publisher":{
"@type":"Organization",
"name": {{ .Site.Title }},
"url": {{ .Site.BaseURL }},
"logo": {
"@type": "ImageObject",
"url": "{{ (default "brand.svg" .Site.Params.logo) | absURL }}",
"width":"32",
"height":"32"
}
},
"image": {{ if .Params.images }}[{{ range $i, $e := .Params.images }}{{ if $i }}, {{ end }}{{ $e | absURL }}{{ end }}]{{ else}}{{.Site.Params.logo | absURL }}{{ end }},
"url" : "{{ .Permalink }}",
"wordCount" : "{{ .WordCount }}",
"genre" : [ {{ range $index, $tag := .Params.tags }}{{ if $index }}, {{ end }}"{{ $tag }}" {{ end }}]
}
</script>
{{ end }}