Files
igaming-template/layouts/partials/head-seo.html
T
2026-07-21 20:54:20 +03:00

97 lines
4.5 KiB
HTML

{{- /* head-seo.html — <title>, meta description, canonical, Open Graph, Twitter,
RSS alternate, and JSON-LD (delegated to schema-jsonld.html). All values
fall back sensibly to brand data. */ -}}
{{- $brand := .Site.Data.brand -}}
{{- $pageTitle := .Params.seoTitle | default .Params.title | default .Title -}}
{{- $title := $pageTitle -}}
{{- if and (not .IsHome) (not (in (lower $pageTitle) (lower $brand.name))) -}}
{{- $title = printf "%s | %s" $pageTitle $brand.name -}}
{{- end -}}
{{- $desc := "" -}}
{{- with .Params.description -}}
{{- $desc = . -}}
{{- else -}}
{{- $desc = .Summary | default .Site.Params.defaultDescription -}}
{{- end -}}
{{- $desc = $desc | plainify | chomp | truncate 160 -}}
{{- /* Per-page OG image override (.Params.image) with fallback to the site default. */ -}}
{{- $imagePath := .Params.image | default .Site.Params.ogImage -}}
{{- $ogImage := cond (ne $imagePath "") ($imagePath | absURL) "" -}}
{{- $ogImageAlt := .Params.imageAlt | default (printf "%s - %s" $brand.name $pageTitle) -}}
{{- $ogLocale := $brand.defaultLocale | default .Language.LanguageCode | default .Language.Lang -}}
{{- range $brand.supportedLocales -}}
{{- if or (eq . $.Language.LanguageCode) (hasPrefix . (printf "%s-" $.Language.Lang)) -}}{{- $ogLocale = . -}}{{- end -}}
{{- end -}}
{{- $isPlaceholderHost := or (in (lower .Site.BaseURL) "example.com") (in (lower .Site.BaseURL) ".example") -}}
{{- $noindex := or .Params.noindex $isPlaceholderHost (eq .Kind "404") -}}
{{- $schemaType := .Params.schemaType | default "none" -}}
{{- $isArticle := in (slice "Article" "Review") $schemaType -}}
{{- $canonical := .Params.canonicalURL | default .Permalink -}}
<title>{{ $title }}</title>
<meta name="description" content="{{ $desc }}">
{{- if ne .Kind "404" }}
<link rel="canonical" href="{{ $canonical }}">
{{- end }}
<meta name="robots" content="{{ if $noindex }}noindex,follow{{ else }}index,follow{{ end }}">
<meta name="author" content="{{ .Params.authorName | default $brand.name }}">
{{- /* Open Graph */ -}}
<meta property="og:type" content="{{ if $isArticle }}article{{ else }}website{{ end }}">
<meta property="og:title" content="{{ $title }}">
<meta property="og:description" content="{{ $desc }}">
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:site_name" content="{{ $brand.name }}">
<meta property="og:locale" content="{{ replace $ogLocale "-" "_" }}">
{{- with $ogImage }}
<meta property="og:image" content="{{ . }}">
<meta property="og:image:alt" content="{{ $ogImageAlt }}">
<meta property="og:image:width" content="{{ $.Params.imageWidth | default 1200 }}">
<meta property="og:image:height" content="{{ $.Params.imageHeight | default 630 }}">
{{- end }}
{{- if and $isArticle (not .Date.IsZero) }}
<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">
{{- end }}
{{- if and $isArticle (not .Lastmod.IsZero) }}
<meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}">
{{- end }}
{{- /* Twitter */ -}}
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="{{ $title }}">
<meta name="twitter:description" content="{{ $desc }}">
{{- with $ogImage }}
<meta name="twitter:image" content="{{ . }}">
<meta name="twitter:image:alt" content="{{ $ogImageAlt }}">
{{- end }}
{{- /* hreflang alternates for the multilingual build. No-op on single-language
sites (.IsTranslated is false), so it is safe to keep permanently. URL
scheme: defaultContentLanguageInSubdir = false (English at root). */ -}}
{{- if .IsTranslated -}}
{{- range .AllTranslations -}}
<link rel="alternate" hreflang="{{ .Language.LanguageCode | default .Language.Lang }}" href="{{ .Permalink }}">
{{- end -}}
{{- /* x-default must point at the site's DEFAULT content language (English at
root), independent of the page currently being rendered. site.Languages
is ordered by weight, so index 0 is the default language. */ -}}
{{- $defaultLang := (index site.Languages 0).Lang -}}
{{- range .AllTranslations -}}
{{- if eq .Language.Lang $defaultLang -}}
<link rel="alternate" hreflang="x-default" href="{{ .Permalink }}">
{{- end -}}
{{- end -}}
{{- range .Translations -}}
<meta property="og:locale:alternate" content="{{ replace (.Language.LanguageCode | default .Language.Lang) "-" "_" }}">
{{- end -}}
{{- end }}
{{ with .OutputFormats.Get "RSS" -}}
<link rel="alternate" type="application/rss+xml" href="{{ .RelPermalink }}" title="{{ $brand.name }} RSS">
{{- end }}
{{ partial "schema-jsonld.html" . }}