]> danix's work - danix.xyz-2.git/commitdiff
fix: breadcrumb uses actual page ancestors instead of hardcoded articles path
authorDanilo M. <redacted>
Wed, 22 Apr 2026 09:48:19 +0000 (11:48 +0200)
committerDanilo M. <redacted>
Wed, 22 Apr 2026 09:48:19 +0000 (11:48 +0200)
Static pages under /is/ now show correct breadcrumb trail (eg. Home / About /
Privacy). Articles still show Home / Articles / Title. Both HTML breadcrumb
and JSON-LD structured data updated.

themes/danix-xyz-hacker/layouts/partials/breadcrumb-jsonld.html
themes/danix-xyz-hacker/layouts/partials/breadcrumb.html

index 3f873a0f9bc2b333fbb02fd4bf2a233ef89d754e..95b5e69db43bfa59b01bc3e18be50f061f558cf5 100644 (file)
@@ -1,10 +1,7 @@
 {{- $homeURL := absURL "/" -}}
-{{- $articlesURL := absURL "/articles/" -}}
 {{- $homeName := i18n "home" -}}
-{{- $articlesName := i18n "articles" -}}
 {{- if eq .Lang "it" -}}
   {{- $homeURL = absURL "/it/" -}}
-  {{- $articlesURL = absURL "/it/articles/" -}}
 {{- end -}}
 <script type="application/ld+json">
 {
       "position": 1,
       "name": "{{ $homeName }}",
       "item": "{{ $homeURL }}"
-    },
-    {
+    }
+    {{- $pos := 1 -}}
+    {{- range .Ancestors.Reverse -}}
+      {{- if ne .Kind "home" -}}
+        {{- $pos = add $pos 1 -}}
+    ,{
       "@type": "ListItem",
-      "position": 2,
-      "name": "{{ $articlesName }}",
-      "item": "{{ $articlesURL }}"
-    },
-    {
+      "position": {{ $pos }},
+      "name": "{{ .Title }}",
+      "item": "{{ .Permalink }}"
+    }
+      {{- end -}}
+    {{- end -}}
+    ,{
       "@type": "ListItem",
-      "position": 3,
+      "position": {{ add $pos 1 }},
       "name": "{{ .Title }}"
     }
   ]
index aa7c1e8bbbcf15db09565c9105a91925fe02b535..c15dfeb64e32f42ddc446ea6870aa87848ef9fb1 100644 (file)
@@ -1,14 +1,16 @@
 {{ $homeLink := "/" }}
-{{ $articlesLink := "/articles/" }}
 {{ if eq .Lang "it" }}
   {{ $homeLink = "/it/" }}
-  {{ $articlesLink = "/it/articles/" }}
 {{ end }}
 
 <nav class="breadcrumb mb-6" aria-label="Breadcrumb">
   <a href="{{ $homeLink }}">{{ i18n "home" }}</a>
-  <span class="breadcrumb-separator">/</span>
-  <a href="{{ $articlesLink }}">{{ i18n "articles" }}</a>
+  {{ range .Ancestors.Reverse }}
+    {{ if ne .Kind "home" }}
+      <span class="breadcrumb-separator">/</span>
+      <a href="{{ .RelPermalink }}">{{ .Title }}</a>
+    {{ end }}
+  {{ end }}
   <span class="breadcrumb-separator">/</span>
   <span>{{ .Title }}</span>
 </nav>