feat: Add a breadcrumb
This commit is contained in:
71
layouts/partials/breadcrumb.html
Normal file
71
layouts/partials/breadcrumb.html
Normal file
@@ -0,0 +1,71 @@
|
||||
<!-- Breadcrumb Navigation with SEO optimization -->
|
||||
<div class="breadcrumb-wrapper">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb" itemscope itemtype="https://schema.org/BreadcrumbList">
|
||||
|
||||
<!-- Home/Accueil with SEO -->
|
||||
<li class="breadcrumb-item" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
|
||||
<a href="{{ "/" | relLangURL }}" itemprop="item" title="{{ i18n "home" | default "Accueil" }}">
|
||||
<i class="fas fa-home" aria-hidden="true"></i>
|
||||
<span itemprop="name">{{ i18n "home" | default "Accueil" }}</span>
|
||||
</a>
|
||||
<meta itemprop="position" content="1" />
|
||||
</li>
|
||||
|
||||
<!-- Category with SEO and linking -->
|
||||
{{ if or .Params.categories .Section }}
|
||||
{{ $category := "" }}
|
||||
{{ $categorySlug := "" }}
|
||||
{{ $categoryUrl := "" }}
|
||||
|
||||
{{ if .Params.categories }}
|
||||
{{ $category = index .Params.categories 0 }}
|
||||
{{ $categorySlug = urlize $category }}
|
||||
{{ $categoryUrl = printf "/categories/%s" $categorySlug }}
|
||||
{{ else if .Section }}
|
||||
{{ $category = humanize .Section }}
|
||||
{{ $categorySlug = .Section }}
|
||||
{{ $categoryUrl = printf "/%s" .Section }}
|
||||
{{ end }}
|
||||
|
||||
{{ if $category }}
|
||||
<li class="breadcrumb-item active" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem" aria-current="page">
|
||||
<a href="{{ $categoryUrl | relLangURL }}" itemprop="item" title="{{ $category }}">
|
||||
<span itemprop="name">{{ $category }}</span>
|
||||
</a>
|
||||
<meta itemprop="position" content="2" />
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
</ol>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- JSON-LD Structured Data for SEO -->
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "BreadcrumbList",
|
||||
"itemListElement": [
|
||||
{
|
||||
"@type": "ListItem",
|
||||
"position": 1,
|
||||
"name": "{{ i18n "home" | default "Accueil" }}",
|
||||
"item": "{{ "/" | absLangURL }}"
|
||||
}{{ if or .Params.categories .Section }},
|
||||
{
|
||||
"@type": "ListItem",
|
||||
"position": 2,
|
||||
"name": "{{ if .Params.categories }}{{ index .Params.categories 0 }}{{ else }}{{ humanize .Section }}{{ end }}",
|
||||
"item": "{{ if .Params.categories }}{{ printf "%s/categories/%s" (absLangURL "") (urlize (index .Params.categories 0)) }}{{ else }}{{ printf "%s/%s" (absLangURL "") .Section }}{{ end }}"
|
||||
}{{ end }}
|
||||
]
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user