Menu

How to find broken #anchor links, the ones every link checker says are fine
📰

How to find broken #anchor links, the ones every link checker says are fine

DEV Community: javascript·linkbruno.com·8 days ago
#yZBSRmsN
Reading 0:00
15s threshold

You rename a heading in your docs from "Install" to "Installation". Your static site generator dutifully changes the heading's id from #install to #installation . Every link that pointed to /docs/setup#install now lands at the top of a long page instead of the section the reader needed.

Your link checker reports no problems. The page returns 200. Technically, nothing is broken.

Fragment links (the #something part of a URL) are one of the quietest kinds of link rot. The server never sees the fragment, so no HTTP check can catch it. Here's how to find them yourself.

Why fragments break so often

The fragment refers to an element with a matching id (or, in older HTML, an <a name="..."> ). Those ids usually come from one of three places:

Auto-generated from headings. Most Markdown tools slugify headings: "Getting Started" becomes #getting-started .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.