Skip to content

linkFragments

Reports link fragments that don't exist in the document.

✅ This rule is included in the md logical presets.

Link fragments (URLs that start with #) should reference valid headings or anchors in the document. This rule helps prevent broken internal links by ensuring that every fragment link points to an existing heading or HTML anchor. It uses GitHub’s heading algorithm for generating heading IDs, ensuring compatibility with how GitHub renders Markdown heading anchors.

[Invalid Link](#non-existent-heading)
# Some Heading
# Some Heading
[Case Mismatch](#other-heading)
# Introduction
[Invalid Link](#introductions)

You might consider disabling this rule if:

  • You are using a Markdown processor or static site generator that has a significantly different algorithm for generating heading IDs
  • You have many dynamically generated links or fragments that cannot be easily validated statically
Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.