Table of Contents in Wordpress Posts

Page content

Add a table of contents in wordpress posts

Wordpress Gutenberg editor has added several new features including the ability to add HTML anchors and more similar exciting features. This feature can be used to add a nice looking table of contents manually to your long posts.

While having a table of contents before your posts may look unnecessary, it does have some significant benefits. First of all, apart from making your posts look more attractive and organized, which improves the user experience, it helps with the SEO part as well. Chances of ranking higher and getting an attractive snipper in the search results increase with a table of content. You will find links from your table of contents included in search snippets so the user can directly jump to the stuff he is looking for.

Especially, if you are used to writing long posts, it becomes pertinent to include a table of contents with it. There are more than one ways to include a Table of contents in your post. You can achieve it using a dedicated plugin, seo plugin or create one manually. Even creating your own manually is not so difficult since some people do not want to use extra plugins for everything.

If you are using the Rank Math plugin for SEO, you can add the table of contents directly to your post using this plugin. It is a slightly new feature that Rank Math has included in its plugin, which is also a testimony to the fact that having a table of contents offers some advantage in SEO terms. There are several dedicated plugins in the wordpress plugin repository you can use to add a table of contents.

Adding a Table of Contents using Easy TOC plugin

Easy TOC table of contents

The easy TOC plugin is a feature rich table of contents plugin that allows you to add a table of content to your posts, without having to manually add shortcode or HTML anchors. If you have an existing large blog with posts in hundreds, you can still add a table of content to all posts using this plugin. It works with Gutenberg and classic editors both as well as page builders like Elementor.

To install the plugin, go to the plugins sections in your wordpress admin dashboard and click on add new. Inside the wordpress repository search for wp TOC, and then install the Easy Table of Contents plugin from here. Activate the plugin and then go to settings in your wordpress dashboard.

You will find the plugin settings at the bottom of the settings section in your wordpress dashboard. Click on it and then change the settings according to your need. For example, if you have several posts that want a table of content inserted in, then select to enable support for posts and then check the box opposite auto insert for posts unless you also want it to appear on static pages. If you do not want the table of contents automatically inserted within the posts, then uncheck the auto insert option.

easy TOC plugin settings

The default appearance position for the table of contents is before the first heading. However, if you want the table of content to appear at the top of each post, change it to top. You can also select the type of posts on which you want the table of contents to appear. For example, if you want it to appear only on the longer posts like posts having more than three headings/subheadings, you change the setting to show when three or more headings are present in a post.

You can also hide the table of contents on initial loading of the page. The table of contents will reveal itself when the user clicks on the button. You will only need to check the toggle view and initial view options to achieve this. To change the look of your table of contents, you can change the counter from decimal to another.

This plugin also offers several themes. If you want a simple table of contents, you can use the default grey theme or change to another that matches your website theme. If you need you can also customize the colors and create your own custom theme.

Near the bottom on the settings page of the plugin, you will also find the option to include and exclude particular headings. If you want, you can uncheck H1 and exclude the title. Similarly, if you don’t want H4 headings included, you can uncheck them. If you want headings containing specific keywords to be excluded from Table of contents, you can do it from the settings.

Setting the plugin is easy and does not require any technical knowledge and can be especially very helpful when you need to automatically insert the TOC on hundreds of pages and want to avoid any manual work. After having changed the settings according to your need, just click on the save changes button. If you do not want to auto insert it on all posts, then you have the shortcode option to add the TOC on select posts. Just add the following shortcode in your post where you want the table of content to appear : [ez-toc]. After adding the TOC, go and check on the front end.

easy TOC settings

You will find most of the features you need to create a good looking table of contents included in the free version of the plugin. However, the pro version also offers a Gutenberg block, which can be used to insert a TOC without any shortcode. The pro version also provides sticky TOC.

Table of Contents using Rank Math:

Rank Math is a very good SEO plugin that comes loaded with features some of which are not available for free in other SEO plugins. It has included a new feature recently called Table of contents block. It comes as a Gutenberg block that you can easily add to your posts using this plugin.

If you are already using this plugin for SEO, you might be familiar with the feature. Otherwise, after installing the Rank Math plugin from the wordpress plugin repository, go to the general settings. You will find the setting for gutenberg blocks at the bottom. Click on blocks and then change the settings for Table of Contents according to your need. For example, you can use the heading ‘Contents’ instead of ‘Table of Contents’. You can also exclude specific headings and select the list style for the table.

Rank Math TOC Block

If you just want a simple Table of content included on the pages where you need it, Rank Math’s table of continent block feature will be more than sufficient. Just insert it using Gutenberg blocks in your posts where you want the TOC to appear.

Add it just like you add any block. Enter TOC in search and then add the Table of Contents by Rank Math block. This will add a table of contents to your post automatically.

Rank Math TOC

Add a Table of Contents Manually

Adding a table of contents manually is easy and when you are starting a new blog, it can be especially helpful to know how to add one to your posts. In this way, you can avoid using an extra plugin on your website. It is as easy as creating a list and then adding anchor links to the elements.

Go to the post to which you want to add the table of contents to. Click on the first heading and then on the right sidebar click on advanced. Add an anchor inside the html anchor box. It can be a letter or a string. For example, if you have five headings in a post, you can add a,b,c,d and e for anchor html against the headings. Just as you added the html anchor to the first heading, add it to the other headings too. Now, move to the top of the page and insert a list there. Add the headings (copy and paste sequentially) to this list. Now, give each heading in the list the form of a link just as you add an anchor link. Highlight the entire heading and add a link. Inside the box for the url, add # and then the letter or string you used for html anchor for that particular heading. If you used the letter a to e for the individual five headings, you can go on adding anchor links starting with # and followed by the specific letter.

In this way, you have created a table of contents for your post. Publish the post and then check at the front end.