From f597beb5c4599e0b1f8238b5c2969071a2a477ab Mon Sep 17 00:00:00 2001 From: Daniel Strobusch <1847260+dastrobu@users.noreply.github.com> Date: Wed, 27 May 2026 13:51:45 +0200 Subject: [PATCH] Fix tabs: use page-level counter for unique group IDs (#817) (#818) .Page.Store.Add is broken in Hugo 0.158+ (returns nil). Additionally, Hugo renders shortcodes bottom-up, so the parent tabs.html cannot pass data to child tab.html via .Store. Fix: - shortcode-id partial: replace .Page.Store.Add with explicit .Page.Store.Set + add, which works in Hugo 0.161+. - tab.html: the first child tab generates a page-unique ID via the partial and caches it on .Parent.Store for siblings. - tabs.html: remove broken .Store.Set "id" line. This avoids the .Parent.Ordinal collision when tabs are nested inside other shortcodes (details, columns, etc.). Fixes #817 --- layouts/_shortcodes/tab.html | 5 ++++- layouts/_shortcodes/tabs.html | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/layouts/_shortcodes/tab.html b/layouts/_shortcodes/tab.html index 888d231..cd11fdb 100644 --- a/layouts/_shortcodes/tab.html +++ b/layouts/_shortcodes/tab.html @@ -1,4 +1,7 @@ -{{- $group := printf "tabs-%v" (.Parent.Store.Get "id") -}} +{{- if not .Ordinal -}}{{- /* first tab sets group ID */ -}} + {{- .Parent.Store.Set "id" (partial "docs/text/shortcode-id" .Parent) -}} +{{- end -}} +{{- $group := printf "tabs-%d" (.Parent.Store.Get "id") -}} {{- $tab := printf "%s-%d" $group .Ordinal -}} {{- /* remove whitespaces */ -}} diff --git a/layouts/_shortcodes/tabs.html b/layouts/_shortcodes/tabs.html index 15e397f..907d01a 100644 --- a/layouts/_shortcodes/tabs.html +++ b/layouts/_shortcodes/tabs.html @@ -1,4 +1,3 @@ -{{- .Store.Set "id" (partial "docs/text/shortcode-id" .) -}} {{- $attributes := partial "docs/text/mapper" (dict "attributes" (cond .IsNamedParams .Params dict) "merge" (dict