How to Create Table of Contents (ToC) in WordPress Posts/Pages?

Creating Table of Contents in WordPress

Creating a Table of Contents section in your posts or pages in WordPress can have many benefits.

Firstly, it improves the user experience.

Since a lot of new content being written for search engines is long-form content, a Table of Contents sections allows users to quickly jump to a section that is relevant for them.

Secondly, A side benefit of having Table of Contents (ToC) is that it individual sections can rank in search engines.

So you don’t need to create separate posts/pages for separate sections.

You can create one mega-article and have links to all these sub-sections using a ToC.

One website that does this really well is Wikipedia.

If I look at the Wikipedia page for SEO, there is the table of contents section in the beginning.

Table of Contents of SEO in Wikipedia

You can easily create this type of ToC on your WordPress posts or pages using a plugin.

Below is a live example of Table of Contents that I have created for this blog post.

And it took me less than 5 seconds to create. I will show you how.

But first!

SEO Benefit of Having Table of Contents

When you have an article that has different sections about a topic, these sub-topics also appear in the search engine results.

For example, if you search for ‘Low Carb Diet’, the result from Healthline shows the main article as well as the links to the sub-topics in it.

Table of Contents Appearing in Search Engine Results

This becomes possible only when you have a Table of Contents that allows the user to click on a topic and jump to that specific section.

Similarly, if I search for ‘Low Card Shopping List’, I again get the same article in the top five Google results.

Example of ToC showing in search result

Note the ‘Jump To Shopping List’ part in the search result. This is made possible as this article has a Table of Contents section on this article.

If you’re using WordPress, it’s super easy to create a ToC using a plugin.

Using Easy Table of Contents Plugin

The best and the easiest way to create Table of Contents is by using a WordPress plugin – Easy Table of Contents.

This plugin has 30,000+ active installs as of writing this article.

Installing of the Easy ToC plugin

Here is a detailed guide on how to install a WordPress Plugin.

Once you have installed and activated this plugin, you can customize the plugin settings by going the Settings –> Table of Contents in the WordPress dashboard.

Table of Content Settings

This will take you to the settings section of the Easy Table of Contents section.

In the settings area, you can specify how the Table of Contents section looks in your blog posts/pages:

  1. You can specify whether you want it to appear on pages/posts or both.
  2. You can auto-insert ToC on pages/posts and specify where it should be inserted (before first heading, after first heading, top, bottom)
  3. You can prevent it from showing up if a page/post has less than the specified number of headers.
  4. You can specify whether you want to show the entire Table of Contents or the collapsed version (with a link to expand it).
  5. You can specify the header label (whether you want to call it Table of Contents or something else).
  6. You can choose from multiple counter bullet formats (none, decimal, numeric, and roman).
  7. You can change the look of the Toc section – width, color, font size etc.

You only need to make these changes once.

Now when you insert a table of contents section in a page/post, it will automatically use these settings.

Inserting the ToC Shortcode Manually

While the plugin has the option to insert a table of contents on all the pages or posts (or both) automatically, you can also disable this and insert it manually.

To insert the TOC in a post/page, just type the following shortcode.

" (without the shortcode)

This shortcode would go through all the headers in your blog post and create a Table of Contents based on it.

Customizing the Table of Contents in Blog Posts/Pages

While the setting section of the Easy ToC plugin allows you to specify the settings for all the ToCs, sometimes, you may also want to customize the Table of Contents on individual posts.

For example, you may want to exclude some headers or may want to use a different header text in the ToC.

Luckily, the Easy Table of Contents plugin allows you to make these changes on a per post/page basis.

Ignore Headers Category (such as H2 or H3 or H4).

If you want to ignore a category of headers (i.e., ignore all H2 headers or H2 and H3 headers), you can do that with Easy Table of Contents settings for that blog post/page.

In the WordPress editor – where you actually write the post – scroll down and you will see the Table of Contents section.

In this section, you can select the headers that you want to include in your posts ToC. When nothing is selected, it will include all the headers, but if you select only H2 and H3, it will only generate a ToC with H2 and H3 headers (and ignore all the other headers).

Table of Content - exclude headers

Creating Alternate Headings

If you want to create an alternate heading for the shortcode, you can do that as well.

Suppose you have a header “Keto Diet: A Beginner’s Guide” in the post, but you want the ToC to show a different header – “Keto Diet Guide“.

To do this, go to the Table of Content settings (below the WordPress editor) and use the following format:

Original Heading | Heading to show in the ToC

So in our example, you need to use the following:

Keto Diet: A Beginner's Guide | Keto Diet Guide

Table of Content - alternate headings

This can be useful when you have headers which are long and you want to keep in short in the ToC that is generated.

Note that these are case sensitive, so you need to use the exact header text for which you want to create an alternate heading.

If you want to change multiple such headers, keep each of it in separate lines in the Alternate Headings box.

Excluding Specific Headers

If you want to exclude specific headers when generating the ToC, you can specify that as well.

For example, you may have an H3 header that you want to exclude from the ToC (but you don’t want to exclude all the H3’s, only a specific one).

This can also be done in the settings area.

Let’s say you want to exclude the header – “What is a Keto Diet?”.

In the settings area of Easy Table of Contents plugin, in the ‘Exclude Headings’ section, specify the header you want to exclude.

Excluding headers in the Easy Table of Contents Plugin

This would show all the other headers, but exclude the one you specified.

In case you want to exclude multiple headers, you can specify those separated by the pipe symbol.

For example, if you want to exclude multiple headers – Keto Diet, Keto Diet Recipes, Meal plan, you can use the following in Exclude headers:

Keto Diet | Keto Diet Recipes | Meal plan

Also, if you want to exclude all the headings that include a specific word, you can also do that using a wildcard character – * (asterisk).

For example, if you want to exclude all headers with the word Keto, use the below in ‘Exclude Headers’ box:


Easy Table of Contents Vs Table of Contents Plus

These are two WordPress plugins that you’ll see everyone recommend when it comes to ToC.

I have used the ToC Plus plugin for many years and migrated away from it when it started acting funny on one of my blogs.

It also came to my notice that the ToC plus plugin has not been updated in a while.

Table of Content Plus

While it’s still one of the highly recommended plugins for ToC and a lot of users are using it, I personally feel more comfortable knowing I have the plugins that are being updated and being worked on.

If you have been a ToC Plus user and want to move to Easy Table of Contents plugin, the transition is seamless.

The shortcode for both the plugins is the same and all your earlier created tables of contents with the ToC plus plugin would continue to work.

11 thoughts on “How to Create Table of Contents (ToC) in WordPress Posts/Pages?”

  1. Hi Sumit,

    Great tutorial. Loved it.

    I’d also love to share our plugin (Ultimate Blocks) with you. It’s Gutenberg blocks plugin that has an advanced “Table of Contents” block.

    By using the plugin, you can add the table of contents anywhere in your posts or pages. You can edit the name of the ToC. You can even show ToC in two or three columns. In a nutshell, it has everything you need to make your ToC awesome.

    I’d like to invite you to check our plugin and give it a try. Hope you’ll love the plugin.

    Thanks & Regards
    Istiak Rayhan

  2. Hi Sumit,

    You have share all the benefits of using toc, I have read some articles where some are discussing bad effects of using toc.

    I would like to know what immediate effects you have noticed on your website, as I noticed that you are also using the same.

    Thank you


Leave a Comment