How to Create a Table of Contents in WordPress

Learn how to create a Table of Contents in WordPress to boost UX and SEO. Explore plugins, shortcodes, and manual methods with step-by-step guides.

A Table of Contents (TOC) is a powerful tool for enhancing user experience (UX) and improving Search Engine Optimization (SEO) on your WordPress website. By providing a clear, clickable outline of your content, a TOC helps readers navigate long-form articles efficiently, allowing them to jump directly to sections that interest them. Additionally, it can boost your site’s SEO by increasing keyword density and improving the chances of securing a featured snippet in Google search results. In this comprehensive guide, we’ll explore why a TOC is essential, the various methods to create one in WordPress (including plugins, shortcodes, and manual coding), and the best styles to implement for maximum impact. We’ll also review top TOC plugins, their features, pricing, and step-by-step instructions to help you choose the right approach for your site.

Why a Table of Contents Matters for Your WordPress Site

A TOC serves as a roadmap for your content, making it easier for visitors to find specific information without scrolling through lengthy posts. This is particularly valuable for in-depth articles, tutorials, or guides where readers may seek answers to specific questions. Here’s why incorporating a TOC is a smart move:

Enhanced User Experience (UX)

Readers often visit your site with targeted queries. A TOC allows them to skip irrelevant sections and jump directly to the content that addresses their needs. This streamlined navigation reduces bounce rates and keeps visitors engaged longer, signaling to search engines that your content is valuable.

SEO Benefits

A TOC can improve your site’s SEO in multiple ways:

  • Keyword Optimization: Including keywords in your TOC’s anchor links increases keyword density, a key ranking factor.
  • Featured Snippets: Google often favors lists, such as TOCs, for featured snippets—those concise summaries displayed at the top of search results. A well-structured TOC can increase your chances of earning this prime real estate.
  • Improved Crawlability: Search engine bots use TOCs to better understand your content’s structure, which can enhance indexing and ranking.

Increased Engagement

A TOC makes your content appear more organized and professional, encouraging readers to explore more sections. It also enables them to read your article in their preferred order, improving their overall experience.

Visual Appeal

A well-designed TOC can enhance the aesthetic of your page, making it look polished and user-friendly. With customizable styles, you can align the TOC with your brand’s visual identity.

Methods to Create a Table of Contents in WordPress

There are three primary ways to add a TOC to your WordPress site: using plugins, shortcodes, or manual coding. Each method has its advantages, depending on your technical expertise, customization needs, and site requirements. Let’s dive into each approach.

Method 1: Adding a Table of Contents Using Plugins

Plugins are the most user-friendly way to add a TOC to your WordPress site, especially for those with limited coding knowledge. They automate the process, generate TOCs based on your headings, and offer customization options. Here’s how to get started:

Step-by-Step Guide to Using a TOC Plugin

1. Install the Plugin:
  • Navigate to Plugins > Add New in your WordPress dashboard.
  • Search for your chosen TOC plugin (e.g., Fixed TOC, Easy Table of Contents, or Heroic Table of Contents).
  • Click Install Now, then Activate. Alternatively, upload a premium plugin’s .zip file if purchased.
2. Configure General Settings:
  • Access the plugin’s settings (usually under Settings or a dedicated menu in the dashboard).
  • Select which post types (e.g., posts, pages, custom post types) should include a TOC.
  • Choose which heading levels (H1, H2, H3, etc.) to include in the TOC.
  • Decide whether the TOC should be automatically inserted or manually placed using a shortcode or block.
3. Customize Appearance:
  • Adjust the TOC’s design, including width, font size, colors, and layout (e.g., numbered, bulleted, or plain list).
  • Some plugins allow you to enable a “show/hide” toggle or sticky behavior for better UX.
4. Apply and Test:
  • Save your settings and preview your site to ensure the TOC appears as expected.
  • Test the jump links to verify they navigate to the correct sections.

Top TOC Plugins for WordPress

Here’s a detailed comparison of the best TOC plugins, including their features, pros, cons, and pricing:

PluginKey FeaturesProsConsPricing
Fixed TOCAuto-generates TOC, 50+ animated effects, sticky option, meta boxes, translation-readyNested subsections, sticky shortcut button, browser compatibilityNot optimized for Gutenberg, sticky TOC may obscure content$20 (one-time)
Heroic Table of ContentsAuto-generates TOC, Gutenberg block, hide specific headings, multiple list stylesGutenberg-optimized, easy drag-and-drop, relabel headingsLimited to 4 styles, minimal customization optionsFree
Easy Table of ContentsAuto-generates TOC, customizable insertion, smooth scrolling, multiple bullet formatsGutenberg-compatible, extensive customization, disable TOC on specific pagesBloated code may slow sites, no manual insertion flexibilityFree
LuckyWP Table of ContentsGutenberg block, shortcode support, show/hide button, customizable designHighly customizable, minimum heading threshold, compatible with select page buildersLimited page builder support, auto-insert may disrupt some pagesFree
Ultimate BlocksGutenberg block, auto-generates TOC, toggle visibility, multi-column layoutsEasy to use, flexible placement, multi-column supportGutenberg-only, limited design customizationFree
Thrive Architect TOCAuto-generates TOC, advanced customization, sticky scroll, multi-column layoutsExtensive design options, sticky scroll with section highlightingRequires Thrive Suite subscription, not standalone$19/month (Thrive Suite)
MultipageDivides posts into subpages, customizable headers, page view analyticsSimplifies long posts, analytics for subpagesLimited CSS customization, requires theme folder editsFree
Table of Contents PlusIndex-style TOC, sidebar placement, shortcode support, customizable positionWikipedia-like design, flexible positioningAuto-insertion limited for custom post typesFree
CM Table of ContentsDefine TOC by class/tag/ID, customizable sections and positionsHighly customizable, supports multi-page TOCs, shortcode placementLess intuitive UIFree

Recommended Plugin: Fixed TOC

For its balance of features and ease of use, Fixed TOC stands out. Its sticky functionality ensures the TOC remains accessible as users scroll, and its 50+ animated effects add a dynamic touch. However, if you’re using the Gutenberg editor and prefer a free option, Heroic Table of Contents or Easy Table of Contents are excellent choices due to their seamless integration.

Method 2: Adding a Table of Contents Using Shortcodes

Shortcodes offer a flexible way to place a TOC anywhere on your WordPress site, such as in posts, pages, or sidebars. They’re especially useful if you want granular control over TOC placement without relying on automatic insertion.

How to Use Shortcodes for a TOC

1. Install a Shortcode-Compatible Plugin:
  • Choose a plugin like LuckyWP Table of Contents or Shortcoder (if your TOC plugin doesn’t support shortcodes natively).
  • Install and activate the plugin as described above.
2. Access or Create the Shortcode:
  • Check the plugin’s documentation for its default shortcode (e.g., [lwptoc] for LuckyWP).
  • Alternatively, use Shortcoder to create a custom shortcode by defining the TOC structure and settings.
3. Insert the Shortcode:
  • Copy the shortcode and paste it into the desired location (e.g., within a post, page, or sidebar widget).
  • For example, in the Gutenberg editor, add a Shortcode block and paste [lwptoc].
4. Customize and Test:
  • Adjust the shortcode parameters (if supported) to modify the TOC’s appearance or behavior.
  • Preview the page to ensure the TOC displays correctly and links work as intended.

Example Shortcode

For LuckyWP Table of Contents, the shortcode might look like:

[lwptoc hide_items="2" depth="3" title="Table of Contents"]

This configures the TOC to hide specific items, limit the heading depth to three levels, and set a custom title.

Benefits of Shortcodes

  • Versatility: Place the TOC in posts, pages, sidebars, or footers.
  • Control: Decide exactly where and when the TOC appears.
  • Compatibility: Works with most page builders and themes.

Method 3: Creating a Table of Contents Manually with HTML

For those comfortable with basic HTML, creating a TOC manually offers complete control without the need for plugins. This method is ideal for lightweight sites or developers who want to avoid additional plugins.

Step-by-Step Guide to Creating a Manual TOC

1. Add Headings to Your Post:
  • In the Gutenberg editor, add headings (H2, H3, etc.) for each section you want in the TOC.
  • Ensure each heading has unique, descriptive text.
2. Assign Unique IDs to Headings:
  • Click on a heading block to reveal the toolbar.
  • Select Edit as HTML from the More Options (three dots) menu.
  • Add a unique ID to the heading tag, e.g.:
    html ¨K35K
  • Repeat for all relevant headings, using unique IDs like section-2, section-3, etc.
3. Create the TOC Structure:
  • Scroll to where you want the TOC (usually near the top of the post).
  • Add a Custom HTML block via the Add Block button.
  • Insert the following HTML, replacing the IDs and section names with your own:
    html ¨K36K
4. Style the TOC (Optional):
  • Add CSS to your theme’s stylesheet or the Additional CSS section in the WordPress Customizer to style the TOC. For example:
    css .toc { background: #f9f9f9; padding: 20px; border-radius: 5px; } .toc ol { list-style-type: decimal; margin: 0; padding-left: 20px; } .toc a { color: #0073aa; text-decoration: none; } .toc a:hover { text-decoration: underline; }
5. Test the TOC:
  • Save the post and preview it on the front end.
  • Click each link to ensure it jumps to the correct section.

Chart: Manual TOC Creation Workflow

To visualize the manual TOC creation process, here’s a flowchart using syntax:

How to Create a Table of Contents in WordPress

Pros and Cons of Manual TOC Creation

  • Pros:
    • Lightweight, no plugins required.
    • Full control over design and placement.
    • Ideal for developers familiar with HTML/CSS.
  • Cons:
    • Requires basic coding knowledge.
    • Time-consuming for large sites with many posts.
    • Manual updates needed if headings change.

Alternative Approach: Using WordPress Templates for a Master TOC

For sites with extensive content, a “master” TOC on a dedicated page (e.g., an archives or links page) can serve as a centralized navigation hub. This approach is particularly useful for content-heavy sites like blogs or documentation portals.

How to Create a Master TOC

1. Choose a Template:
  • Check if your theme includes an archives.php or links.php template.
  • If not, create a custom page template by copying page.php and renaming it (e.g., toc-master.php).
2. Customize the Template:
  • Edit the template to list your site’s content (e.g., posts, categories, or pages) as a TOC.
  • Example code for a simple master TOC:
    php <?php /* Template Name: Master TOC */ get_header(); ?> ¨K37K <?php get_footer(); ?>
3. Create a Page:
  • In the WordPress dashboard, go to Pages > Add New.
  • Assign the custom template to the page and publish it.
4. Link to the Master TOC:
  • Add a link to the master TOC in your site’s navigation menu or footer.

Example: Master TOC Structure

A master TOC might look like this:

  • Categories:
    • Tutorials
    • Plugins
    • Themes
    • SEO
  • Recent Posts:
    • How to Optimize Your WordPress Site
    • Best Plugins for 2025
    • Creating a TOC in WordPress

This approach is ideal for sites with extensive archives, as it provides a single page for users to explore all content.

Popular Table of Contents Styles

The style of your TOC can significantly impact its usability and visual appeal. Here are two popular styles and how to implement them:

1. Floating Table of Contents

A floating TOC remains fixed on the screen (typically on the side) as users scroll, ensuring constant accessibility. This is ideal for long posts where users may need to refer to the TOC frequently.

Implementation Steps

1. Create the TOC:
  • Use a plugin like Fixed TOC or a manual HTML method to generate the TOC.
  • Place the TOC in a widget area (e.g., sidebar) or as a block in your post.
2. Make It Sticky:
  • Install the Q2W3 Fixed Widget plugin.
  • Go to Appearance > Widgets, locate your TOC widget, and check the Fixed Widget option.
  • Alternatively, use CSS to make the TOC sticky:
    css .toc { position: sticky; top: 20px; }
3. Test Responsiveness:
  • Ensure the TOC doesn’t obscure content on mobile devices. Adjust its width or position as needed.

Example: Floating TOC

A floating TOC might appear as a sidebar widget that scrolls with the user, with links like:

  • Introduction
  • Plugin Setup
  • Manual TOC Creation
  • SEO Benefits

2. Sidebar Table of Contents

A sidebar TOC is a static element placed in a fixed sidebar, typically to the left or right of the content. Unlike a floating TOC, it doesn’t move with the scroll but remains part of the page’s layout.

Implementation Steps

1. Add the TOC to a Sidebar:
  • Use a plugin’s shortcode (e.g., [lwptoc]) or a manual HTML block in a sidebar widget.
  • Go to Appearance > Widgets and add a Custom HTML or Shortcode widget to your sidebar.
2. Customize the Design:
  • Use the plugin’s settings or custom CSS to style the TOC to match your theme.
  • Example CSS:
    css .sidebar-toc { background: #fff; padding: 15px; border: 1px solid #ddd; }
3. Test Placement:
  • Ensure the TOC fits well within the sidebar and doesn’t disrupt the layout on smaller screens.

Example: Sidebar TOC

A sidebar TOC might resemble Wikipedia’s index-style navigation, with a clean, bulleted list of section links.

Choosing the Right TOC Approach for Your Site

Selecting the best method depends on your site’s needs, technical expertise, and budget:

  • Beginners: Use a free plugin like Heroic Table of Contents or Easy Table of Contents for simplicity and Gutenberg compatibility.
  • Developers: Opt for manual HTML for full control and minimal plugin dependency.
  • Content-Heavy Sites: Consider a master TOC template for centralized navigation.
  • Premium Users: Invest in Fixed TOC or Thrive Architect for advanced features and sticky functionality.

Best Practices for Implementing a TOC

To maximize the effectiveness of your TOC, follow these tips:

  • Keep It Concise: Only include major headings (H2, H3) to avoid overwhelming readers.
  • Use Descriptive Labels: Ensure TOC links clearly describe the section content.
  • Optimize for Mobile: Test the TOC on mobile devices to ensure it’s user-friendly.
  • Incorporate Keywords: Add relevant keywords to TOC links for SEO benefits.
  • Update Regularly: If using a manual TOC, update links when modifying headings.

Conclusion

Adding a Table of Contents to your WordPress site is a simple yet impactful way to enhance UX and SEO. Whether you choose a plugin for automation, shortcodes for flexibility, or manual coding for control, a TOC can make your content more accessible and engaging. By selecting the right style—floating or sidebar—and following best practices, you can create a seamless navigation experience that keeps readers on your site longer and boosts your search rankings. Start implementing a TOC today to transform your long-form content into a user-friendly, SEO-optimized resource.

Please share these How to Create a Table of Contents in WordPress with your friends and do a comment below about your feedback.

We will meet you on next article.

Until you can read, Sweet Soy Ramen Noodles with Duck and Spinach

Leave a Comment