MD051 - Link Fragments
Link fragments should be valid.
Why This Rule Exists
Fragment links (anchors) like #section-name should point to actual headings
in the document. Invalid fragments create broken navigation.
Examples
Incorrect
# Introduction
See the [configuration](#config) section.
## Configuration Options
Content here.
The fragment #config doesn't match #configuration-options.
Correct
# Introduction
See the [configuration](#configuration-options) section.
## Configuration Options
Content here.
How Fragments Are Generated
Headings become fragments by:
- Converting to lowercase
- Replacing spaces with hyphens
- Removing special characters
| Heading | Fragment |
|---|---|
## Getting Started | #getting-started |
## API Reference | #api-reference |
## What's New? | #whats-new |
Configuration
This rule has no configuration options.
When to Disable
- Documents with custom anchor IDs
- Content using JavaScript-based navigation
- Files processed by tools that modify anchors
Rule Details
- Rule ID: MD051
- Aliases: link-fragments
- Category: Links
- Severity: Warning
- Auto-fix: No
Performance
This rule is optimized for large documents. It builds a heading index once and validates all fragments efficiently.