To insert a Table of Contents (TOC) in WordPress, start by installing a TOC plugin. Log in to your WordPress dashboard and go to Plugins > Add New. Search for “Table of Contents” and select a popular plugin like Easy Table of Contents or LuckyWP Table of Contents. Click Install Now and then Activate the plugin. I personally use LuckyWP Table of Contents, its main features are:
- Automatical insertion of a table of contents (configure post types and position).
- SEO-friendly: table of contents code is ready to use by Google for snippets on result page.
- Insert by shortcode, Gutenberg block, or widget.
- Button on the toolbar of the classic editor.
- Gutenberg block into “Common Blocks”.
- Setting the minimum number of headings to display a table of contents.
- Setting the depth of headings for a table of contents.
- Skip headings by level or text.
- Hierarchical or linear view.
- Numeration items: decimal or Roman numbers in order or nested.
- Customizable appearance: width, float, title font size and weight, items font size, colors.
- Color schemes (dark, light, white, transparent, inherited from theme) and the ability to override colors.
- Toggle Show/Hide (optionally)
- Customizable labels.
- Smooth scroll (optionally).
- Setting offset top for the smooth scroll.
- Wrap table of contents with <!–noindex–> tag (optionally).
- Pretty hash in the URL (like
example.com/faq/#how_do_this
). - RTL support.
- Override global settings are available for a particular post.
- Highly compatible with WordPress themes and plugins.
Once activated, configure the plugin settings by navigating to Settings > Table of Contents (or the specific plugin name). Here, you can adjust how and where the TOC will appear, including options for automatic insertion into posts or pages, which headings (H1, H2, H3, etc.) to include, and customization of the TOC’s appearance.
If you prefer to insert the TOC manually, you can use the TOC block or shortcode provided by the plugin. For instance, adding [toc]
In the desired location within your post or page, you will place the Table of Contents.
Finally, save your post or page. The Table of Contents will automatically display according to your settings, enhancing navigation for your readers.