MediumScott BatsonExplainer
How we built the new Table of Contents feature
Summary
Medium built a new Table of Contents feature after an existing Chrome extension demonstrated demand, while its approach of inserting a static list into post content created revision, maintenance, navigation, and reading-experience problems. The shipped implementation derives a nested list from the rendered post body at runtime: H2 and H3 become top-level entries, H4 headings nest beneath the latest top-level heading, and lead title, subtitle, and kicker are excluded. It appears as a right-margin indicator that scrolls with the reader, highlights the current heading, supports smooth scrolling, and uses a sliding window for posts with many headings. Full-width images receive a translucent background, one-heading posts hide the feature, and mobile needs a separate solution because desktop indicators overlap content; the feature took a couple of days, mostly for UX testing and design iteration.
Context
The existing Chrome extension was popular, indicating user demand, but its static table of contents modified post content, did not update after revisions, forced readers to return to the top, and made navigation feel abrupt. The post’s revision-based model also made generating the feature from stored revisions less practical.
Approach / What changed
The feature is generated from the final rendered post body at runtime. H2 and H3 headings become top-level entries, H4 headings are nested beneath the latest top-level heading, and lead title, subtitle, and kicker are excluded. A right-margin interface provides current-position highlighting, smooth scrolling, image-aware visibility, and a sliding window for long lists.
Takeaways
Generating the table of contents at render time keeps it synchronized with revisions and avoids adding index content to the post itself.
The desktop interface uses long and short heading indicators, current-heading highlighting, smooth scrolling, a translucent background over full-width images, and a sliding window for posts with many headings.
Mobile requires a separate design because the desktop indicators overlap the narrower post content; Medium also states that table-of-contents scrolling does not affect valid reads or earnings.
Source and freshness
- Source
- medium.engineering
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.