You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Identical heading text results in duplicate anchor IDs #42
When multiple headings contain the same text, the Anchors plugin generates duplicate id attributes for those headings.
For example, the following content:
<h2>Link Examples</h2>
<h3>Hover and Focus</h3>
<p>...</p>
<h2>Image Examples</h2>
<h3>Hover and Focus</h3>
<p>...</p>
is rendered as:
<h2 id="link-examples">Link Examples</h2>
<h3 id="hover-and-focus">Hover and Focus</h3>
<p>...</p>
<h2 id="image-examples">Image Examples</h2>
<h3 id="hover-and-focus">Hover and Focus</h3>
<p>...</p>
This results in duplicate IDs within the same document, which produces invalid HTML and breaks anchor navigation, table-of-contents links, etc. that relies on unique IDs.
The plugin should ensure generated IDs are unique, similar to how it is done for entry slugs. For example by appending a numeric suffix (hover-and-focus, hover-and-focus-2, etc.) when duplicate heading text is encountered.
Steps to reproduce
Create content containing two or more headings with identical text.
Render the content using the Anchors plugin.
Inspect the generated HTML.
Observe that each identical heading receives the same id attribute.
Activity
linear-code commentedon Jun 8, 2026
PT-3138