eleventy
eleventy copied to clipboard
The IdAttributePlugin can create conflicts
Operating system
macOS Sonoma 14.6.1
Eleventy
3.0.0-beta.1
Describe the bug
The plugin does not check for existing id attributes in the markup, only ones created for headers previously. That means the following markup (from a real example):
<section id="thank-you">
<h2>Thank you!</h2>
<p>…</p>
</section>
Will output
<section id="thank-you">
<h2 id="thank-you">Thank you!</h2>
<p>…</p>
</section>
Solutions
There are two solutions I can think of:
- Allow users to opt-out (or in) on a per-page basis. Ones of the sites I manage had two occurrances of clashing
idattributes as a result of adding this plugin, but many pages don't actually need theids for the headers. It'd be nice if I could opt-in on a per-page basis, so that these issues would be less prevalent. - Alternatively, and I recognize this might be more computationally expensive; check the entire page HTML for
idattributes to avoid the conflicts.
Fixed in #3430
Upstream #3363