Use the TOC Node module to automatically add a Table Of Contents to your Drupal pages.

Table Of Contents

You might be familiar with Table Of Contents (TOC) in books and reports, the web version of TOC are not as common, but can be very usefull for navigating long pages.


TOC styled

TOC Node Module

The TOC Node module scans all the heading of a page and displays them as a linked outline at the top of the page. It can also add a "Move to top" link next to each heading, so users can quickly navigate back to the TOC.

TOC Node module was developed by Code Positive for a government client, released as a contributed module in 2014, and there are now 200+ sites using it.

Currently it's only available for Drupal 7, but there's a Drupal 8 version on the way.

Options Per Content Type

Table Of Contents can be enabled per content type, each with it's own settings, which is useful if say you always want TOC on Articles, sometimes on Blogs, but never on Events.


Content type settings

The first option to set is whether to add a TOC to the content type or not. Content types that always have short content  don't usually need a TOC.

The Back to top links option is for the "Move to top" links that appear next to each heading and navigate back to the top of the page. As well being able to show or hide the links, you can also make it optional for each node and set defaults either way.

The Level option is for what level of headings to include in the TOC. If you set it to h2 all smaller headings (h3, h4,...) will not be added to the TOC.

The Styles available and Display default options add controls to individual nodes - how to display the TOC (using bullet points, a numbered list, or no display), and what the default should be.

Options Per Node

TOC options on individual nodes are useful if you only want to add TOC to pages with a lot of content and need to decide on a node by node basis.


Node options

Table Of Contents Display

When enabled on a node the TOC will display just below the title of the page.

There's also the option of adding the TOC to pages as a block, giving the flexibility of displaying it anywhere on the page. Note that if the TOC is displayed as a block it won't automatically be shown below the page title.


Table of contents block

Similar Modules

There are quite a few other Drupal modules that provide Table Of Contents to pages.

The TOC Node module is different from these as it scans all the visible content of a node rather than just one field, and uses PHP DOMDocument to manipulate content, which in most cases will be faster and more accurate than the regex approach used by other modules.

Module Info