How to build a table of contents.

A Table of Contents From Headings

I was elbow-deep in a client’s backend last Tuesday—the kind of site that feels like it was built by someone who hates their own users—when I realized they were trying to solve their navigation issues by installing yet another heavy, bloated plugin. It’s the same old story: people think they need a massive, resource-hogging suite just to figure out how to build a table of contents that actually works. They treat a simple structural necessity like it’s some high-level engineering feat, when in reality, they’re just adding more digital junk to an already cluttered house.

I’m not here to sell you on a premium “all-in-one” solution that will slow your site to a crawl. Instead, I’m going to show you how to approach this with a designer’s eye and a developer’s restraint. We’re going to look at how to map out your content hierarchy first, so that when you finally decide how to build a table of contents, it feels like a seamless part of the design rather than a clunky afterthought. No fluff, no bloat—just clean, functional structure.

Table of Contents

Mastering Document Structure With Headings First

Mastering Document Structure With Headings First.

Before you even think about touching a plugin or a sidebar widget, you need to get your house in order. I’ve inherited more “broken” sites than I care to count, and nine times out of ten, the issue isn’t the code—it’s that the content is a disorganized mess. If you want a functional TOC, you have to respect the hierarchy. Stop treating your H2s and H3s like stylistic choices; they are the architectural bones of your page. You cannot build a reliable map if the landmarks keep shifting or don’t exist in the first place.

This is where most people trip up. They try to force an automatic table of contents in Word or a fancy WordPress plugin to fix a structural disaster, but the tech can’t manufacture logic where there is none. You need to establish a clear document structure with headings that follows a logical nesting pattern. If your H3 is floating around without an H2 to anchor it, your navigation will be a nightmare. Think of it like typeface pairing: if the hierarchy is off, the whole visual language collapses. Get your heading levels sorted first, and the rest of the technical heavy lifting becomes trivial.

The Markdown Table of Contents Syntax Shortcut

The Markdown Table of Contents Syntax Shortcut.

If you’re writing in a text editor or managing documentation via GitHub, stop trying to manually code every single link. I’ve spent enough hours un-building broken layouts to know that manual entry is just a recipe for a broken site later. Instead, lean into the markdown table of contents syntax. It’s essentially a way to tell your editor, “Hey, look at my headings and do the heavy lifting for me.” You aren’t just typing text; you’re creating a map that follows the logic you already established in your document structure with headings.

The “shortcut” is really just about using brackets and parentheses to point toward your IDs. You write the title in brackets, followed by a link to the heading in lowercase, replacing spaces with hyphens. It sounds simple, but if you get the slug wrong, your creating clickable navigation links effort becomes a total waste of time. It’s much cleaner than hunting through a bloated wordpress toc plugin guide every time you want to update a single line. Once you master this syntax, you stop fighting the editor and start actually writing.

Stop Treating Your TOC Like an Afterthought

  • Stop building the list before the content exists. I’ve seen people spend twenty minutes formatting a perfect table of contents only to realize their actual headings don’t match a single link. Write the damn article first; the structure will reveal itself.
  • Don’t over-nest or you’ll end up with a visual mess. If your TOC has four levels of indentation, your reader is going to lose their place faster than a client losing a login credential. Keep it to two levels—H2s and maybe an H3 if it actually matters.
  • Watch your anchor text. If your TOC link says “Section 1” but the heading is “Why Your Page Builder is Killing Your LCP,” you’ve failed. The TOC should be a roadmap, not a riddle.
  • Check your IDs manually if you aren’t using a plugin. There is nothing more frustrating than clicking a link in a TOC and watching the page jump to the wrong spot because someone named a heading “Introduction” twice.
  • Keep it lean. If your article is 300 words, you don’t need a table of contents. A TOC is for navigation, not for padding out a page that’s already too thin. Don’t add complexity just because you think it looks “professional.”

Stop Guessing and Start Structuring

Stop Guessing and Start Structuring hierarchy.

At the end of the day, building a table of contents isn’t about adding a shiny new feature to your page; it’s about respecting the hierarchy you’ve already established. If you’ve done the heavy lifting by mastering your heading structure and utilizing the right Markdown shortcuts, the TOC becomes a natural byproduct rather than a manual chore. Don’t let a messy document dictate your user experience. Whether you are working in a clean text editor or wrestling with a bloated CMS, remember that logic must precede aesthetics. If your foundation is solid, the navigation will follow.

I’ve spent way too many hours cleaning up sites where the “navigation” was just a collection of random links that led nowhere. Don’t be that developer. Treat your document structure like a well-designed typeface—every element should have a specific purpose and a clear place in the visual hierarchy. When you build a table of contents that actually reflects your content’s DNA, you aren’t just helping the reader; you are asserting control over your digital space. Go build something that actually makes sense.

About Rasheeda Volkov

A theme is a set of decisions somebody else made. I read them before installing.

Author photo