Auto-generated table of contents for Flarum posts. Builds anchors from Markdown headings (#, ##, ###) and renders an inline TOC at the top of each post that has 2+ headings.
composer require linkrobins/toc
Then enable it in your forum's admin panel under Extensions.
Auto-generated table of contents for Flarum posts. Builds anchors from Markdown headings (#, ##, ###) and renders an inline TOC at the top of each post that has two or more headings.
Works in two places out of the box:
.Post-body is rendered).LinkRobinsBlog-post-body)For every heading in a post, the extension:
For each post with two or more headings, the extension prepends a compact "Contents" card listing every heading as a navigable link, indented by heading depth.
Two settings, both with sensible defaults:
| Setting | Default | What |
|---|---|---|
linkrobins-toc.max_depth |
3 |
Highest heading level included in the TOC (1, 2, or 3) |
linkrobins-toc.min_headings |
2 |
TOC is hidden unless the post has at least this many headings |
These currently have no admin UI — set them via the Flarum settings API or directly in the settings table. An admin panel can be added later if needed.
Within a single post, ids are stable and predictable:
section fallback-2, -3, suffixes3-introduction) so two posts on the same page don't fight over #introductionThe result is that linking to a section is just <post URL>#<id>. Hovering a heading shows a small link icon; clicking copies the URL.