Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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:

  1. Converting to lowercase
  2. Replacing spaces with hyphens
  3. Removing special characters
HeadingFragment
## 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.

  • MD024 - Duplicate headings
  • MD042 - Empty links
  • MD052 - Reference links and images
  • MDBOOK002 - Internal link validation