This repository has been archived on 2025-08-21. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
hugo-mistergeek/layouts/partials/seo/structured-data.html
2025-08-19 12:57:31 +02:00

133 lines
3.6 KiB
HTML

{{- $title := .Title | default .Site.Title -}}
{{- $description := .Description | default .Summary | default .Site.Params.description | default .Site.Title -}}
{{- $image := .Params.image | default .Site.Params.seo.default_image | default "/assets/images/logo.png" -}}
{{- $image = $image | absURL -}}
{{- $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": "{{ .Site.Params.description }}",
"url": "{{ .Site.BaseURL }}",
"logo": {
"@type": "ImageObject",
"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", "TechArticle"],
"headline": "{{ $title }}",
"description": "{{ $description }}",
"image": {
"@type": "ImageObject",
"url": "{{ $image }}",
"width": 1200,
"height": 630
},
"url": "{{ $url }}",
"author": {
"@type": "Person",
"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 }}",
"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">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Accueil",
"item": "{{ .Site.BaseURL }}"
}{{ if .Section }},
{
"@type": "ListItem",
"position": 2,
"name": "{{ .Section | humanize }}",
"item": "{{ .Site.BaseURL }}{{ .Section }}/"
}{{ if .Title }},
{
"@type": "ListItem",
"position": 3,
"name": "{{ $title }}",
"item": "{{ $url }}"
}{{ end }}{{ end }}
]
}
</script>
{{ end }}