How to Create a Table of Contents in WordPress Posts and Pages


Want to add a table of contents to your WordPress posts or pages?

A table of contents can make a long article easier to navigate and improve your site’s SEO. However, they can be difficult for beginners to create.

In this article, we will show you how to create a table of contents in WordPress posts and pages.

How to Create a Table of Contents in WordPress Posts and Pages

Why Add a Table of Contents to Posts and Pages in WordPress?

You may have seen the table of contents on sites like Wikipedia. We also use them on WPBeginner for our long guides such as our ultimate guide to WordPress speed and performance.

You can add a table of contents to articles on your WordPress website to make it easier to jump from section to section of a long article.

Not only do they improve the user experience, but they will also help your WordPress SEO. This is because Google can use the table of contents to automatically add “go to section” links in search results.

Google includes table of contents entries in search results

A table of contents can also help your post get listed as a featured snippet at the top of the search engine results page. This will help you get the most SEO traffic.

Tables of contents are also used in featured snippets

That being said, let’s take a look at how to create a table of contents in WordPress posts and pages. We’ll show you how to do it automatically with a plugin and manually using anchor links:

Automatically add a table of contents in WordPress

AIOSEOalso known as All in One SEO, is the best WordPress SEO plugin and it comes with an inbuilt content table block for WordPress.

We recommend this method because it saves you time by automatically generating the table of contents based on your subtitles, while making it fully customizable with editable links.

The first thing you need to do is install the free software All in one SEO Lite connect. For more details, see our step-by-step guide on how to install a WordPress plugin.

You just need the free version to easily add a table of contents, but AIOSEO Pro offers even more features to help you rank better in search engine results pages.

Upon activation, you will need to configure the plugin using the AIOSEO Setup Wizard. For step-by-step instructions, see our guide on setting up All in One SEO for WordPress correctly.

Add a table of contents with AIOSEO

You will need to create or edit the post or page where you want to add the table of contents. After that, click on the blue ‘+’ icon and locate the ‘AIOSEO – Table of Contents’ block.

Add an AIOSEO table of contents block to the post or page

Simply drag the block onto the post or page where you want the table of contents to appear.

To note: Once you have added a table of contents, you may notice that the ‘AIOSEO – Table of contents’ block will be greyed out. Indeed, you can only have one table of contents per post or page.

The plugin will automatically identify page titles and add them to your table of contents. If you use different heading levels (say H2 and H3), the lower level headings will be indented to show the structure of your content.

If you are still writing content for your post or page, any headings added to the document will automatically be added to the table of contents.

Customize the table of contents with AIOSEO

There are several ways to customize the table of contents to suit your needs. For example, you can click on a title to rename it. This will rename the title in the table of contents, but not the article.

Customizing your table of contents

AIOSEO will automatically create anchor links for each topic. You can click the Link icon to edit the anchor text, and this is changed in both the table of contents and the post content header.

You can also click the eye icon next to any of the headers to hide it. AIOSEO Pro users can rearrange headings in the table of contents block. This will rearrange the headings in the table of contents, but not in the article.

You will also find a setting for the block in the sidebar. Here you can choose a bulleted or numbered list style for your table of contents.

Your table of contents can be in a bulleted or numbered list

Finally, when you are done customizing your table of contents, you should click on the “Done” button to save your changes.

You will now be able to see what the table of contents will look like for your visitors.

Your table of contents is a list of links to the titles of the post or page

It’s a good idea to add a heading or paragraph above the table of contents. This will make it clear to your readers that they are looking at a table of contents.

When your visitors click on a link in the table of contents, they will immediately be taken to that heading in the article. This allows users to jump directly to the section that interests them the most.

Anchor link preview

The reason we like AIOSEO’s table of contents feature over other WordPress table of contents plugins is that it allows you to customize headings and hide headings selectively if necessary.

This is an essential feature that most other table of contents plugins simply don’t have.

Add a Table of Contents Manually in WordPress

You can also create a table of contents manually using anchor links, without the need for a plugin. However, it will take more time and effort.

You can learn more about anchor links in our guide on how to add anchor links in WordPress.

Type the table of contents

First, you need to add a “List” block where you can add the table of contents headings. You can either type the headings in the list or copy and paste them one by one from your article content.

You must enter a list of headers

How to Add Anchor Text to Header Blocks

Next, you’ll need to add an anchor attribute to each heading you want to reference in the table of contents. This will let WordPress know where to jump when a visitor clicks on the title in the table of contents.

First you need to click on the title, such as H2 or H3. Next, you need to click on the “Advanced” arrow in the block settings pane to show the advanced settings.

After that, enter a unique word or phrase without spaces in the “Anchor HTML” field. If you want, you can use hyphens to separate each word.

You must create an HTML anchor attribute for each title

Then simply repeat this for all other headings that will be included in the table of contents.

Index: If you paste the header into this field, hyphens will be added automatically. This is an easy way to create a unique identifier that also clearly represents the title.

Add anchor links to table of contents

The final step is to link the table of contents headings to the HTML anchors you created.

You need to highlight the first entry in your List block, then click the “Link” icon in the toolbar.

Highlight the title text and click the link icon

Next, you need to enter a hashtag (#) and then type or paste the anchor text for that title.

The # tells WordPress to jump to that section of the current post. You don’t add the domain name or other URL parameters.

Type a hashtag, then the anchor text

Once done, you need to press “Enter” or click on the “Submit” icon to create the link.

The anchor link will be added to your table of contents. When your visitors click on this link, they will immediately be taken to this header in the post or page content.

An anchor link is added to the table of contents

You can repeat these steps to add anchor links to other headings in the table of contents.

We hope this tutorial helped you learn how to create a table of contents in WordPress posts and pages. You might also want to learn how to increase your blog traffic or check out our list of must-have plugins to grow your site.

If you liked this article, subscribe to our Youtube channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Create a Table of Contents in WordPress Posts and Pages first appeared on WPBeginner.



Leave a Comment

Your email address will not be published.