Add a Table Of Contents to Drupal pages

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 useful for navigating long pages.

Image
Table of contents

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.

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.

Image
Options per content type

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.

Image
TOC 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.

Image
TOC block display

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

Download: TOC Node Module