1
Files
2025/layouts/partials/head/metadata.html
2026-03-16 21:21:27 +01:00

68 lines
2.5 KiB
HTML

{{- $title := site.Title -}}
{{- if not .IsHome -}}
{{- $title = printf "%s | %s" .Title site.Title -}}
{{- end -}}
{{- $socialTitle := site.Title -}}
{{- if not .IsHome -}}
{{- $socialTitle = .Title -}}
{{- end -}}
{{- $description := partial "head/description.html" . -}}
{{- $socialImage := partial "head/social-image.html" . -}}
{{- $openGraphImage := $socialImage.openGraph -}}
{{- $twitterImage := $socialImage.twitter -}}
{{- $noindex := partial "seo/noindex.html" . -}}
{{- $pageClassification := partial "seo/page-classification.html" . -}}
{{- $robots := "max-image-preview:large" -}}
{{- if $noindex -}}
{{- $robots = "noindex, follow" -}}
{{- end -}}
{{- $ogType := index $pageClassification "openGraphType" -}}
{{- $localeCode := site.LanguageCode | default site.Language.LanguageCode | default "fr-FR" -}}
{{- $locale := replace $localeCode "-" "_" -}}
<title>{{ $title }}</title>
{{- with $description }}
<meta name="description" content="{{ . }}">
{{- end }}
<meta name="theme-color" content="{{ site.Params.themeColor | default "#060c14" }}">
<meta name="robots" content="{{ $robots }}">
<link rel="canonical" href="{{ .Permalink }}">
<meta property="og:locale" content="{{ $locale }}">
<meta property="og:site_name" content="{{ site.Title }}">
<meta property="og:type" content="{{ $ogType }}">
<meta property="og:title" content="{{ $socialTitle }}">
<meta property="og:url" content="{{ .Permalink }}">
{{- with $description }}
<meta property="og:description" content="{{ . }}">
{{- end }}
{{- with $openGraphImage.url }}
<meta property="og:image" content="{{ . }}">
{{- end }}
{{- with $openGraphImage.width }}
<meta property="og:image:width" content="{{ . }}">
{{- end }}
{{- with $openGraphImage.height }}
<meta property="og:image:height" content="{{ . }}">
{{- end }}
{{- with $openGraphImage.alt }}
<meta property="og:image:alt" content="{{ . }}">
{{- end }}
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="{{ $socialTitle }}">
{{- with $description }}
<meta name="twitter:description" content="{{ . }}">
{{- end }}
{{- with $twitterImage.url }}
<meta name="twitter:image" content="{{ . }}">
{{- end }}
{{- with $twitterImage.alt }}
<meta name="twitter:image:alt" content="{{ . }}">
{{- end }}
{{- if and (eq $ogType "article") (index $pageClassification "isArticleLike") -}}
{{- with .Date }}
<meta property="article:published_time" content="{{ .Format "2006-01-02T15:04:05Z07:00" }}">
{{- end }}
{{- with .Lastmod }}
<meta property="article:modified_time" content="{{ .Format "2006-01-02T15:04:05Z07:00" }}">
{{- end }}
{{- end -}}