aboutsummaryrefslogtreecommitdiff
path: root/layouts/single.html
diff options
context:
space:
mode:
authorNicholas Johnson <>2026-09-18 00:00:00 +0000
committerNicholas Johnson <>2026-09-19 16:06:44 -0400
commit4f22a1ee6092762ee116dc09b3cea66b181e3efffe22eb56037c6e41b11757d8 (patch)
tree572120701b12f11814404622120829a78001a42c5fd00244208378bd34466524 /layouts/single.html
parent57722d8190902f0c91f53317b3699a11cffb01b05cc28c3eadff83c244bba4eb (diff)
downloadhugo-theme-journal-4f22a1ee6092762ee116dc09b3cea66b181e3efffe22eb56037c6e41b11757d8.tar.gz
hugo-theme-journal-4f22a1ee6092762ee116dc09b3cea66b181e3efffe22eb56037c6e41b11757d8.zip
Fix entry heading anchors on page bundles
The heading id came from .File.TranslationBaseName, which is "index" for every leaf bundle. Since audio versions require an entry to be a bundle, every entry with audio got the same meaningless anchor, and pages built by a content adapter would have taken the name of the directory holding the adapter. Derive the id from the page's own URL instead. Single file entries keep the anchors they already had, and bundles, adapter built pages and custom slugs now each get their own. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'layouts/single.html')
-rw-r--r--layouts/single.html5
1 files changed, 4 insertions, 1 deletions
diff --git a/layouts/single.html b/layouts/single.html
index e7522a0..9ea21f4 100644
--- a/layouts/single.html
+++ b/layouts/single.html
@@ -3,8 +3,11 @@
<p>{{ emojify ":link:" }}&nbsp;<a class="link link--internal" href="{{ .Site.Home.RelPermalink }}" rel="noreferrer">{{ i18n "returnHome" }}</a></p>
</nav>
<main class="main">
+ {{/* derived from the page's own URL so that it is stable and unique for
+ single files, page bundles and pages built by a content adapter alike */ -}}
+ {{ $headingID := path.Base .RelPermalink | strings.TrimSuffix ".html" -}}
<div class="entry__details">
- <h1 id="{{ .File.TranslationBaseName }}" class="entry__heading">{{ .Title }}</h1>
+ <h1 id="{{ $headingID }}" class="entry__heading">{{ .Title }}</h1>
{{- if (.Page.Params.pageinfo | default true) }}
<p class="entry__pageinfo">{{ partial "pageinfo.html" . }}</p>
{{- end -}}