improve seo

This commit is contained in:
a 2024-01-23 15:04:46 -06:00
parent add9440485
commit cc93948c7d

View file

@ -1,7 +1,11 @@
{{ "<!-- title -->" | safeHTML }} {{ "<!-- title -->" | safeHTML }}
{{ $firstH1 := partial "name.html" . }} {{- $firstH1 := partial "name.html" . }}
{{ $title := or .Title $firstH1 $.File.ContentBaseName }} {{- $title := or .Title $firstH1 $.File.ContentBaseName }}
{{- if $title }}
<title itemprop="name">{{ $title }} - {{ .Site.Title }}</title> <title itemprop="name">{{ $title }} - {{ .Site.Title }}</title>
{{- else }}
<title itemprop="name">{{ .Site.Title }}</title>
{{- end }}
<meta property="og:title" content="{{ $title }}" /> <meta property="og:title" content="{{ $title }}" />
<meta name="twitter:title" content="{{ $title }}" /> <meta name="twitter:title" content="{{ $title }}" />
<meta name="application-name" content="{{ .Site.Title }}" /> <meta name="application-name" content="{{ .Site.Title }}" />
@ -13,7 +17,7 @@
<meta itemprop="description" content="{{.}}" /> <meta itemprop="description" content="{{.}}" />
<meta property="og:description" content="{{.}}" /> <meta property="og:description" content="{{.}}" />
<meta name="twitter:description" content="{{.}}" /> <meta name="twitter:description" content="{{.}}" />
{{ end -}} {{ end }}
{{ "<!-- url -->" | safeHTML }} {{ "<!-- url -->" | safeHTML }}
<base href="{{ .Permalink | absURL }}"> <base href="{{ .Permalink | absURL }}">
<link rel="canonical" href="{{ .Permalink | absURL }}" itemprop="url" /> <link rel="canonical" href="{{ .Permalink | absURL }}" itemprop="url" />
@ -55,7 +59,7 @@
{{/*=== published and updated ===*/}} {{/*=== published and updated ===*/}}
{{ "<!-- time -->" | safeHTML }} {{ "<!-- time -->" | safeHTML }}
{{- with .Date }} {{ with .Date }}
<meta property="og:article:published_time" content={{ .Format "2006-01-02T15:04:05Z0700" | safeHTML }} /> <meta property="og:article:published_time" content={{ .Format "2006-01-02T15:04:05Z0700" | safeHTML }} />
<meta property="article:published_time" content={{ .Format "2006-01-02T15:04:05Z0700" | safeHTML }} /> <meta property="article:published_time" content={{ .Format "2006-01-02T15:04:05Z0700" | safeHTML }} />
{{ end -}} {{ end -}}
@ -79,7 +83,7 @@
{ {
"@context": "http://schema.org", "@context": "http://schema.org",
"@type": "Article", "@type": "Article",
"headline": {{ .Title }}, "headline": {{ $title }},
"author": { "author": {
"@type": "Person", "@type": "Person",
"name": "{{ or .Params.author .Site.Params.author }}" "name": "{{ or .Params.author .Site.Params.author }}"
@ -90,15 +94,15 @@
"mainEntityOfPage": "True", "mainEntityOfPage": "True",
"dateModified": "{{ .Lastmod.Format "2006-01-02" }}", "dateModified": "{{ .Lastmod.Format "2006-01-02" }}",
"image": { "image": {
"@type": "imageObject", "@type": "ImageObject",
"url": "{{ with or .Params.cover $cover $icon }}{{ .Permalink | absURL }}{{ end }}" "url": "{{ with or .Params.cover $cover $icon }}{{ .Permalink | absURL }}{{ end }}"
}, },
"publisher": { "publisher": {
"@type": "Person", "@type": "Person",
"name": "{{ or .Params.author .Site.Params.author .Site.Title }}", "name": "{{ or .Params.author .Site.Params.author .Site.Title }}",
"logo": { "logo": {
"@type": "imageObject", "@type": "ImageObject",
"url": {{with $icon}}{{.Permalink}}{{else}}{{$staticIcon}}{{end}} "url": {{with $icon}}{{.Permalink}}{{else}}{{$staticIcon}}{{end}}
} }
} }
} }