seo fixes

This commit is contained in:
a 2024-02-26 12:22:30 -06:00
parent 09039f4fee
commit cc40a43b00

View file

@ -1,11 +1,15 @@
{{- $firstH1 := partial "name.html" . }}
{{- $title := or .Title $firstH1 $.File.ContentBaseName }}
{{- $name := or .Params.name (print $title " - " .Site.Title) }}
{{- $cover := ($.Resources.ByType "image").GetMatch "{*cover*,*thumbnail*,*featured*}" -}}
{{ $icon := resources.GetMatch (default "" .Site.Params.icon) -}}
{{/*=== title ===*/}} {{/*=== title ===*/}}
{{ "<!-- text -->" | safeHTML }} {{ "<!-- text -->" | safeHTML }}
{{- with .Site.Title }} {{- with .Site.Title }}
<meta name="application-name" property="og:site_name" content="{{ . }}" /> <meta name="application-name" property="og:site_name" content="{{ . }}" />
{{- end -}} {{- end -}}
{{- $firstH1 := partial "name.html" . }}
{{- $title := or .Title $firstH1 $.File.ContentBaseName }}
{{- $name := or .Params.name (print $title " - " .Site.Title) }}
{{- if .IsHome}} {{- if .IsHome}}
{{- $name = or .Params.name .Site.Title }} {{- $name = or .Params.name .Site.Title }}
{{- end }} {{- end }}
@ -28,8 +32,6 @@
{{- end -}} {{- end -}}
{{/*=== image ===*/}} {{/*=== image ===*/}}
{{- $cover := ($.Resources.ByType "image").GetMatch "{*cover*,*thumbnail*,*featured*}" -}}
{{ $icon := resources.GetMatch (default "" .Site.Params.icon) -}}
{{- $staticIcon := "icon.png" | absURL -}} {{- $staticIcon := "icon.png" | absURL -}}
{{- with or $cover $icon }} {{- with or $cover $icon }}
{{ "<!-- image -->" | safeHTML }} {{ "<!-- image -->" | safeHTML }}
@ -59,8 +61,8 @@
{{- end -}} {{- end -}}
{{/*=== published and updated ===*/}} {{/*=== published and updated ===*/}}
{{ "<!-- time -->" | safeHTML -}} {{- "<!-- time -->" | safeHTML }}
{{ with .Date }} {{ with .Date -}}
<meta property="og:article:published_time" content={{ .Format "2006-01-02T03:04:05Z" | safeHTML }} /> <meta property="og:article:published_time" content={{ .Format "2006-01-02T03:04:05Z" | safeHTML }} />
<meta property="article:published_time" content={{ .Format "2006-01-02T03:04:05Z" | safeHTML }} /> <meta property="article:published_time" content={{ .Format "2006-01-02T03:04:05Z" | safeHTML }} />
{{ end -}} {{ end -}}
@ -69,7 +71,7 @@
{{ end -}} {{ end -}}
{{/*=== section and keywords ===*/}} {{/*=== section and keywords ===*/}}
{{- "<!-- keywords -->" | safeHTML }} {{- "<!-- keywords -->" | safeHTML -}}
{{ with.Params.category -}} {{ with.Params.category -}}
<meta property="article:section" content="{{ . }}" /> <meta property="article:section" content="{{ . }}" />
{{- end -}} {{- end -}}
@ -91,7 +93,7 @@
"url": {{ .Site.BaseURL }} "url": {{ .Site.BaseURL }}
}, },
"datePublished": {{ .Date.UTC.Format "2006-01-02T03:04:05Z" }}, "datePublished": {{ .Date.UTC.Format "2006-01-02T03:04:05Z" }},
"description": {{ or .Description .Summary }}, "description": {{ (or .Description .Summary) | plainify }},
"wordCount": {{ .WordCount }}, "wordCount": {{ .WordCount }},
"mainEntityOfPage": {{.Permalink}}, "mainEntityOfPage": {{.Permalink}},
"dateModified": "{{ .Lastmod.UTC.Format "2006-01-02T03:04:05Z" }}", "dateModified": "{{ .Lastmod.UTC.Format "2006-01-02T03:04:05Z" }}",
@ -114,14 +116,14 @@
{{ "<!-- webpage metadata -->" | safeHTML }} {{ "<!-- webpage metadata -->" | safeHTML }}
<meta property="og:type" content="website" /> <meta property="og:type" content="website" />
<script defer type="application/ld+json"> <script defer type="application/ld+json">
{ {
"@context": "http://schema.org", "@context": "http://schema.org",
"@type": "WebPage", "@type": "WebPage",
"name": "{{ .Title }}", "name": {{ .Title }},
"url": {{ .Permalink }}, "url": {{ .Permalink }},
"description": "{{ or .Description .Summary }}", "description": {{ (or .Description .Summary) | plainify }},
"logo": {{with $icon}}{{.Permalink}}{{else}}{{$staticIcon}}{{end}} "logo": {{with $icon}}{{.Permalink}}{{else}}{{$staticIcon}}{{end}}
} }
</script> </script>
{{- end -}} {{- end -}}
@ -140,6 +142,6 @@
{{- end -}} {{- end -}}
{{/* robots */}} {{/* robots */}}
{{- "<!-- robots -->" | safeHTML }} {{ "<!-- robots -->" | safeHTML }}
<meta name="robots" content="index,follow" /> <meta name="robots" content="index,follow" />
<meta name="googlebot" content="index,follow" /> <meta name="googlebot" content="index,follow" />