Mutualiser les calculs SEO du head
This commit is contained in:
36
layouts/partials/head/data.html
Normal file
36
layouts/partials/head/data.html
Normal file
@@ -0,0 +1,36 @@
|
||||
{{- $page := . -}}
|
||||
{{- $title := $page.Site.Title -}}
|
||||
{{- if not $page.IsHome -}}
|
||||
{{- $title = printf "%s | %s" $page.Title $page.Site.Title -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $socialTitle := $page.Site.Title -}}
|
||||
{{- if not $page.IsHome -}}
|
||||
{{- $socialTitle = $page.Title -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $description := partial "head/description.html" $page -}}
|
||||
{{- $socialImage := partial "head/social-image.html" $page -}}
|
||||
{{- $noindex := partial "seo/noindex.html" $page -}}
|
||||
{{- $pageClassification := partial "seo/page-classification.html" $page -}}
|
||||
{{- $robots := "max-image-preview:large" -}}
|
||||
{{- if $noindex -}}
|
||||
{{- $robots = "noindex, follow" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $localeCode := $page.Site.LanguageCode | default $page.Site.Language.LanguageCode | default "fr-FR" -}}
|
||||
|
||||
{{- return dict
|
||||
"title" $title
|
||||
"socialTitle" $socialTitle
|
||||
"description" $description
|
||||
"socialImage" $socialImage
|
||||
"openGraphImage" ($socialImage.openGraph | default dict)
|
||||
"twitterImage" ($socialImage.twitter | default dict)
|
||||
"noindex" $noindex
|
||||
"pageClassification" $pageClassification
|
||||
"robots" $robots
|
||||
"ogType" (index $pageClassification "openGraphType")
|
||||
"localeCode" $localeCode
|
||||
"locale" (replace $localeCode "-" "_")
|
||||
-}}
|
||||
Reference in New Issue
Block a user