Table of contents block ruins heading anchors
-
I installed this plugin to get a simple table of contents. The TOC block worked well, responds well, and looks nice. I was happy with how it worked overall.
Then I realized it rewrote all of my heading anchors and broke a bunch of links on my page. It has 3 crucial flaws regarding heading anchors
- The TOC block adds its own anchors to all headings on a page, overwriting user-specified anchors.
- The generated anchors begin with a number based on the order of headings in the page.
- The anchors update when I change the text of a heading
For (1) I had specified multiple internal anchor links on my page. After I added the TOC block, they were ALL broken.
(2) Means that I can never reliably link to a heading anchor again. If I have heading 1 and heading 2 and link to heading 2, my link will break if I add a heading between heading 1 and heading 2.
(3) means that if I change the text of a heading, the anchor changes and again my links break.
Please
- Respect user anchors. If one exists, do NOT overwrite it. A user put it there for a reason.
- Omit numbers from anchors to minimize churn
- Once an anchor is set, don’t change it even if the heading text changes
- The topic ‘Table of contents block ruins heading anchors’ is closed to new replies.