Add more features for SEO

This commit is contained in:
kbe
2025-08-19 12:57:31 +02:00
parent 7adeb66c6c
commit 2bced48437
11 changed files with 1136 additions and 35 deletions

View File

@@ -5,46 +5,103 @@
{{- $url := .Permalink | default .RelPermalink | absURL -}}
{{- $siteName := .Site.Title -}}
{{- $logo := .Site.Params.seo.logo | default "/assets/images/logo.png" | absURL -}}
{{- $author := .Params.author | default .Site.Params.author | default .Site.Title -}}
{{- $datePublished := .Date.Format "2006-01-02T15:04:05Z07:00" -}}
{{- $dateModified := .Lastmod.Format "2006-01-02T15:04:05Z07:00" -}}
{{- $keywords := delimit (.Keywords | default .Site.Params.keywords | default (slice)) ", " -}}
<!-- Enhanced WebSite Schema -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebSite",
"name": "{{ $siteName }}",
"description": "{{ $description }}",
"description": "{{ .Site.Params.description }}",
"url": "{{ .Site.BaseURL }}",
"logo": {
"@type": "ImageObject",
"url": "{{ $logo }}"
}
"url": "{{ $logo }}",
"width": 400,
"height": 400
},
"potentialAction": {
"@type": "SearchAction",
"target": {
"@type": "EntryPoint",
"urlTemplate": "{{ .Site.BaseURL }}search?q={search_term_string}"
},
"query-input": "required name=search_term_string"
},
"inLanguage": "fr-FR",
"dateModified": "{{ now.Format "2006-01-02T15:04:05Z07:00" }}"
}
</script>
<!-- Enhanced Article Schema -->
{{ if .IsPage }}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Article",
"@type": ["Article", "TechArticle"],
"headline": "{{ $title }}",
"description": "{{ $description }}",
"image": "{{ $image }}",
"image": {
"@type": "ImageObject",
"url": "{{ $image }}",
"width": 1200,
"height": 630
},
"url": "{{ $url }}",
"author": {
"@type": "Person",
"name": "{{ .Params.author | default .Site.Params.author | default .Site.Title }}"
"name": "{{ $author }}",
"url": "{{ .Site.BaseURL }}",
"sameAs": [
"https://twitter.com/mistergeekfrance",
"https://www.linkedin.com/in/mistergeek",
"https://www.youtube.com/@mistergeek"
]
},
"publisher": {
"@type": "Organization",
"name": "{{ $siteName }}",
"url": "{{ .Site.BaseURL }}",
"logo": {
"@type": "ImageObject",
"url": "{{ $logo }}"
"url": "{{ $logo }}",
"width": 400,
"height": 400
}
},
"datePublished": "{{ $datePublished }}",
"dateModified": "{{ $dateModified }}",
"inLanguage": "fr-FR",
"keywords": "{{ $keywords }}",
"articleSection": "{{ .Section | default "general" }}",
"wordCount": {{ .WordCount }},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "{{ $url }}"
}
}
</script>
{{ end }}
<!-- Tutorial-specific Schema -->
{{ if eq .Section "tutorials" }}
{{ partial "seo/schema-tutorial.html" . }}
{{ end }}
<!-- Enhanced Article Schema for blog posts -->
{{ if or (eq .Section "blog") (eq .Section "posts") }}
{{ partial "seo/schema-article.html" . }}
{{ end }}
<!-- Local SEO Schema -->
{{ if .IsHome }}
{{ partial "seo/schema-local.html" . }}
{{ end }}
<!-- Breadcrumb Schema -->
{{ if and .IsPage .Section }}
<script type="application/ld+json">
@@ -57,28 +114,19 @@
"position": 1,
"name": "Accueil",
"item": "{{ .Site.BaseURL }}"
}
{{ if .Section }}
,{
}{{ if .Section }},
{
"@type": "ListItem",
"position": 2,
"name": "{{ .Section | humanize }}",
"item": "{{ .Site.BaseURL }}{{ .Section }}/"
}
,{
}{{ if .Title }},
{
"@type": "ListItem",
"position": 3,
"name": "{{ $title }}",
"item": "{{ $url }}"
}
{{ else }}
,{
"@type": "ListItem",
"position": 2,
"name": "{{ $title }}",
"item": "{{ $url }}"
}
{{ end }}
}{{ end }}{{ end }}
]
}
</script>