mirror of
https://github.com/theNewDynamic/gohugo-theme-ananke.git
synced 2025-06-08 17:22:46 +00:00
Added schema to improve SEO.
This commit is contained in:
parent
f6d5e27225
commit
3e59ad2e51
@ -57,6 +57,8 @@
|
||||
<meta name="twitter:image" content="{{ . | absURL }}" >
|
||||
{{ end }}
|
||||
|
||||
{{- partial "site-schema.html" . -}}
|
||||
|
||||
{{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") }}
|
||||
{{ template "_internal/google_analytics_async.html" . }}
|
||||
{{ end }}
|
||||
|
121
layouts/partials/site-schema.html
Normal file
121
layouts/partials/site-schema.html
Normal file
@ -0,0 +1,121 @@
|
||||
{{ if .IsHome -}}
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "http://schema.org",
|
||||
"@type": "WebSite",
|
||||
"url": "{{ .Site.BaseURL }}",
|
||||
{{ if .Site.Author.name -}}
|
||||
"author": {
|
||||
"@type": "Person",
|
||||
"name": "{{ .Site.Author.name }}"
|
||||
},
|
||||
{{- end }}
|
||||
{{ if .Site.Params.description -}}
|
||||
"description": "{{ .Site.Params.description }}",
|
||||
{{- end }}
|
||||
{{ with .Site.Params.image -}}
|
||||
"image": "{{ .url | absURL }}",
|
||||
{{- end }}
|
||||
{{ with .Site.Params.logo -}}
|
||||
"thumbnailUrl": "{{ .url | absURL }}",
|
||||
{{- end }}
|
||||
{{ with .Site.Copyright -}}
|
||||
"license": "{{ . }}",
|
||||
{{- end }}
|
||||
"name": "{{ .Site.Title }}"
|
||||
}
|
||||
</script>
|
||||
{{- else if .IsPage -}}
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "http://schema.org",
|
||||
"@type": "BlogPosting",
|
||||
"headline": "{{ .Title }}",
|
||||
"mainEntityOfPage": {
|
||||
"@type": "WebPage",
|
||||
"@id": "{{ .Permalink }}"
|
||||
},
|
||||
{{ if isset .Params "featured_image" -}}
|
||||
"image": {
|
||||
"@type": "ImageObject",
|
||||
"url": "{{ .Params.featured_image | absURL }}"
|
||||
},
|
||||
{{- else -}}
|
||||
"image": {
|
||||
"@type": "ImageObject",
|
||||
"url": "{{ .Site.Params.image.URL | absURL }}",
|
||||
"width": {{ .Site.Params.image.width | absURL }},
|
||||
"height": {{ .Site.Params.image.height | absURL}}
|
||||
},
|
||||
{{- end }}
|
||||
"genre": "{{ .Type }}",
|
||||
{{ with .Params.tags -}}
|
||||
"keywords": "{{ delimit . ", " }}",
|
||||
{{- end }}
|
||||
"wordcount": {{ .WordCount }},
|
||||
"url": "{{ .Permalink }}",
|
||||
{{ if not .PublishDate.IsZero -}}
|
||||
"datePublished": "{{ .PublishDate.Format "2006-01-02T15:04:05-07:00" | safeHTML }}",
|
||||
{{- else if not .Date.IsZero -}}
|
||||
"datePublished": "{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}",
|
||||
{{- end }}
|
||||
{{ with .Lastmod -}}
|
||||
"dateModified": "{{ .Format "2006-01-02T15:04:05-07:00" | safeHTML }}",
|
||||
{{- end }}
|
||||
{{ with .Site.Copyright -}}
|
||||
"license": "{{ . }}",
|
||||
{{- end }}
|
||||
{{ with .Site.Params.publisher -}}
|
||||
"publisher": {
|
||||
"@type": "Organization",
|
||||
"name": "{{ .name }}",
|
||||
"logo": {
|
||||
"@type": "ImageObject",
|
||||
"url": "{{ .logo.url | absURL }}",
|
||||
"width": {{ .logo.width }},
|
||||
"height": {{ .logo.height }}
|
||||
}
|
||||
},
|
||||
{{- end }}
|
||||
{{ if .Params.author -}}
|
||||
"author": {
|
||||
"@type": "Person",
|
||||
"name": "{{ .Params.author }}"
|
||||
},
|
||||
{{- else if .Site.Author.name -}}
|
||||
"author": {
|
||||
"@type": "Person",
|
||||
"name": "{{ .Site.Author.name }}"
|
||||
},
|
||||
{{- end }}
|
||||
"description": "{{ .Description }}"
|
||||
}
|
||||
</script>
|
||||
{{- else -}}
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "http://schema.org",
|
||||
"@type": "WebSite",
|
||||
"url": "{{ .Site.BaseURL }}",
|
||||
{{ if .Site.Author.name -}}
|
||||
"author": {
|
||||
"@type": "Person",
|
||||
"name": "{{ .Site.Author.name }}"
|
||||
},
|
||||
{{- end }}
|
||||
{{ if .Site.Params.description -}}
|
||||
"description": "{{ .Params.title }}: {{ .Params.description }}",
|
||||
{{- end }}
|
||||
{{ with .Site.Params.image -}}
|
||||
"image": "{{ .url | absURL }}",
|
||||
{{- end }}
|
||||
{{ with .Site.Params.logo -}}
|
||||
"thumbnailUrl": "{{ .url | absURL }}",
|
||||
{{- end }}
|
||||
{{ with .Site.Copyright -}}
|
||||
"license": "{{ . }}",
|
||||
{{- end }}
|
||||
"name": "{{ .Site.Title }}"
|
||||
}
|
||||
</script>
|
||||
{{- end }}
|
Loading…
x
Reference in New Issue
Block a user