Skip to content

Add a table of contents to your posts

Table of Contents builds a navigation list from the H2–H6 headings in a post. It can appear at the top of the post, in the left or right gutter, or in a sidebar widget. As the reader scrolls, it highlights the current section and opens any nested headings beneath it.

Before you start

Add a table of contents to a post type

To add a table of contents to every post in a post type:

  1. Go to the post type's Settings screen (for example Blog → Settings) and open the Layout tab.
  2. Check Add Table of Contents.
  3. Choose a Position: Top of post (default), Left gutter, or Right gutter.
  4. Optionally check Make sticky — at the top of the post the TOC collapses into a bar that stays on screen as the reader scrolls and expands on click.
  5. Save settings.

Gutter placements require a layout with no sidebar and no page builder active. If neither condition is met, the TOC falls back to the top of the post.

The Layout settings tab showing the Add Table of Contents checkbox, Position menu, and Make sticky option

Enable the table of contents for a post type from its Layout settings.

Add or remove the table of contents on a single post

Each post can override the post type's default.

  • To add a TOC to a post whose type does not add one: open the post in the editor, find the Table of Contents field in Page Settings, and check Add Table of Contents.
  • To remove a TOC from a post whose type does add one: the same field shows as Remove Table of Contents. Check it.

Show the table of contents in a widget

The MD → Table of Contents widget (Appearance → Widgets) adds the TOC to any widget area. Set a title if you want a heading above the list. The widget only shows on single posts, and it stays hidden when the post's Layout already adds a TOC — it never appears twice.

How it works

  • Headings are organized as an ordered list. H3–H6 headings are nested under the H2 before them in collapsible sublists.
  • Clicking a link scrolls smoothly to the heading and updates the URL hash. A direct link to #heading-id scrolls to it on page load.
  • Scroll positions account for the WordPress admin bar and MD's sticky header.
  • On screens under 900px the TOC shows as an expandable bar fixed to the bottom of the screen.
  • Headings are read when a post is saved. Posts written before you installed the Drop-in need to be re-saved before a TOC appears on them.

Check the result

Open a post that has the TOC enabled and scroll through it. The current heading should be highlighted in the list. Click a heading link — the page should scroll to it. On a mobile device or narrow window, the TOC should collapse into a bottom bar. If a TOC does not appear on an older post, open it in the editor and save it again.

Alex Mangini

Hi, I'm Alex! I started writing about web design and blogging at 13 years old, which turned into client work, which led to building my own software. 15 years later I'm still at it, and Marketers Delight is the epitome of my philosophy for building on the web.