Heading links
CoreCreatedJun 1, 2026Takeshi Takatsudo
Automatically adds slug-based id attributes and anchor links to every heading.
HeadingLinksPlugin is always active. It slugifies every <h2>–<h6>
and injects a self-referencing anchor link so readers can copy a deep-link
to any section.
Behaviour
For each heading the plugin:
- Computes a GitHub-slugger-compatible slug from the heading text.
- Deduplicates repeated slugs within the same document by appending a
counter (
overview,overview-1,overview-2, …). - Sets the
idattribute on the<h*>element. - Wraps the heading text in an
<a href="#slug">anchor.
Example
## Introduction
## Introduction
Produces:
<h2 id="introduction"><a href="#introduction">Introduction</a></h2>
<h2 id="introduction-1"><a href="#introduction-1">Introduction</a></h2>
Config
Always on, no config key. The slug algorithm is fixed (GitHub-slugger
rules) and cannot be customised from zfb.config.ts.
Ordering note
HeadingLinksPlugin runs first in the hast phase. Plugins that depend
on stable heading id values — such as TocPlugin (opt-in
heading-marker-toc) and
TocExportPlugin (opt-in toc-export) —
must run after it.
See also
- Heading-marker TOC — opt-in TOC
insertion that reads the
idattributes this plugin produces. - TOC export — opt-in structured TOC data export.