LoveIt/layouts/partials/head/seo.html
Dillon f14301c395
feat: improve configuration (#245)
* feat: improve configuration

* fix: fix partials/footer.html error
2020-04-21 22:55:06 +08:00

109 lines
3.6 KiB
HTML

{{- $params := .Scratch.Get "params" -}}
{{- with .Site.Params.verification.google -}}
<meta name="google-site-verification" content="{{ . }}" />
{{- end -}}
{{- with .Site.Params.verification.bing -}}
<meta name="msvalidate.01" content="{{ . }}" />
{{- end -}}
{{- with .Site.Params.verification.yandex -}}
<meta name="yandex-verification" content="{{ . }}" />
{{- end -}}
{{- with .Site.Params.verification.pinterest -}}
<meta name="p:domain_verify" content="{{ . }}" />
{{- end -}}
{{- with .Site.Params.verification.baidu -}}
<meta name="baidu-site-verification" content="{{ . }}" />
{{- end -}}
{{- /* Home SEO */ -}}
{{- if .IsHome -}}
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "{{ .Permalink }}",
{{- with .Site.LanguageCode -}}
"inLanguage": "{{ . }}",
{{- end -}}
{{- with .Site.Author.name -}}
"author": {
"@type": "Person",
"name": "{{ . | safeJS }}"
},
{{- end -}}
{{- with .Site.Params.description -}}
"description": "{{ . | safeJS }}",
{{- end -}}
{{- with $params.seo.image -}}
"image": "{{ .url | absURL }}",
{{- end -}}
{{- with $params.seo.logo -}}
"thumbnailUrl": "{{ .url | absURL }}",
{{- end -}}
{{- with .Site.Copyright -}}
"license": "{{ . | safeJS }}",
{{- end -}}
"name": "{{ .Site.Title | safeJS }}"
}
</script>
{{- /* Page SEO */ -}}
{{- else if .IsPage -}}
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BlogPosting",
"headline": "{{ .Title | safeJS }}",
"inLanguage": "{{ .Site.LanguageCode }}",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "{{ .Permalink }}"
},
{{- if ge $params.seo.image.width 696 -}}
"image": {
"@type": "ImageObject",
"url": "{{ $params.seo.image.url | absURL }}",
"width": {{ $params.seo.image.width }},
"height": {{ $params.seo.image.height }}
},
{{- end -}}
"genre": "{{ .Type }}",
{{- with .Params.tags -}}
"keywords": "{{ delimit . ", " }}",
{{- end -}}
"wordcount": {{ .WordCount }},
"url": "{{ .Permalink }}",
{{- if not .PublishDate.IsZero -}}
"datePublished": "{{ .PublishDate.Format "2006-01-02" }}",
{{- else if not .Date.IsZero -}}
"datePublished": "{{ .Date.Format "2006-01-02" }}",
{{- end -}}
{{- with .Lastmod -}}
"dateModified": "{{ .Format "2006-01-02" }}",
{{- end -}}
{{- with .Site.Copyright -}}
"license": "{{ . | safeJS }}",
{{- end -}}
{{- with $params.seo.publisher -}}
"publisher": {
"@type": "Organization",
"name": "{{ .name | safeJS }}",
"logo": {
"@type": "ImageObject",
"url": "{{ .logo.url | absURL }}",
"width": {{ .logo.width }},
"height": {{ .logo.height }}
}
},
{{- end -}}
{{- with .Params.author | default .Site.Author.name | default (T "author") -}}
"author": {
"@type": "Person",
"name": "{{ . | safeJS }}"
},
{{- end -}}
"description": "{{ .Description | safeJS }}"
}
</script>
{{- end -}}