Fix: use deterministic IDs for code block copy buttons - #471
Draft
danielledeleo wants to merge 1 commit into
Draft
Fix: use deterministic IDs for code block copy buttons#471danielledeleo wants to merge 1 commit into
danielledeleo wants to merge 1 commit into
Conversation
❌ One or more of the commit messages in this PR do not match the nginx-hugo-theme git guidelines, please check the CI job for more details on which commits were flagged and why.Please do not close this PR and open another, instead modify your commit message(s) with git commit --amend and force push those changes to update this PR. |
✅ Deploy Preview will be available once build job completes!
|
danielledeleo
force-pushed
the
deterministic-code-block-ids
branch
from
April 1, 2026 16:54
6940e33 to
976785d
Compare
danielledeleo
marked this pull request as draft
April 1, 2026 18:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
now.UnixNano-based element IDs with a simple ordinal counterrender-codeblock.html(fenced code blocks) andghcode.html(shortcode)Problem
Code block copy buttons were assigned IDs like
id-18a245ee1c0763adusing the wall-clock nanosecond timestamp at render time. This made HTML output non-deterministic — 40 out of 1,571 files differed between clean rebuilds of unchanged source, breaking content-addressable caching, diffing, and reproducible deployments.Solution
.Ordinalis Hugo's zero-based per-page counter. Different prefixes (cb-vsgh-) prevent collisions if both templates are used on the same page. Output IDs are clean and readable:cb-0,cb-1,cb-2, etc.