Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Geocoder 8.x-4.37 Minor update available for module geocoder (8.x-4.37). Release: Workflow Modeler 1.0.9 Minor update available for module modeler (1.0.9). Release: Vite 1.5.6 Minor update available for module vite (1.5.6). Release: Postmark Webhooks 1.2.0 Minor update available for module postmark_webhooks (1.2.0). Release: FileGate 1.10.0 Minor update available for module file_gate (1.10.0). Release: Menu Autopilot 1.4.0 Minor update available for module menu_autopilot (1.4.0). Release: Field Guard 1.3.0 Minor update available for module field_guard (1.3.0). Release: Audit Chain 1.9.0 Minor update available for module audit_chain (1.9.0). Module Revived: Decorative Images 1.3.6 Module decorative_images updated after 7 months of inactivity (1.3.6). Security Coverage: Pixie Dark Theme pixie_dark now has official Drupal security advisory coverage.

Paragraphs Table of Contents

130 sites Security covered Drupal 8–11
View on drupal.org

This module automatically generates an in-page table of contents for pages built with the Paragraphs module. It creates links for each paragraph, allowing visitors to easily navigate long content. The module displays these links in a block, typically in a sidebar, and scrolls the page to the corresponding section when a link is clicked.

Overview

If you have long pages on your site, then it helps visitors if you can provide in-page navigation, or a table of contents.

If you build your long pages with the Paragraphs module, then you can use Paragraphs Table of Contents to provide the in-page navigation. There is one link in the table of contents (ToC) for each paragraph on the page.

Currently, this module is very simple, basically a proof of concept. If you think this module could be useful on your sites if only it were a little more convenient, then create an issue with a bug report or a feature request. The more interest this module gets, the more likely I am to improve it.

The screenshot shows a sample page with several sections (paragraphs) including some nested ones. The table of contents is in the left sidebar, and each line is a link to the corresponding section on the page. In order to make the structure clear, I have added some CSS to create a border and a margin around each paragraph on the page.

How It Works

Most of the work is done through configuration: paragraph types, view modes, and a view to create the ToC block. There is a little custom code that helps with the theming, so that the entries in the table of contents are links to the corresponding sections on the page.

  • View modes: The "Table of Contents" view mode for paragraphs (toc) shows only the title (field_ptoc_title) and nested paragraphs (using the same view mode). Similarly, the "Table of Contents" view mode for nodes shows just the paragraphs field (field_ptoc_sections) in this view mode.
  • View: the view (ptoc_table_of_contents) creates a block using the node ID (nid) from the current page. That block simply displays the current node in "Table of Contents" view.
  • Custom code: A preprocess function adds an id attribute to paragraphs that use the default view mode, so that they can be targeted by links. Theme functions tell Drupal to use a custom Twig template for paragraphs that use the toc view mode. This template makes the title an in-page link to the default view of the paragraph.

Screenshots

Here are some screenshots of a fully themed site using this module, thanks to @SirClickALot.

View of the top of a page showing the PTOC block in place on the left and the corresponding Paragraph title (LEARN) on the right...

View after clicking on the second first-level TOC link (CHECK) showing a scroll down to the corresponding Paragraph title (CHECK) on the right...

View after clicking on a second-level TOC link (Decimal value of a byte) showing a scroll down to the corresponding title heading on the right...

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
3
Tracked since
Dec 2024
Latest release
2 months ago
Releases (12 mo)
2 ▲ from 1
Maintenance
Active

Release Timeline

Releases

Version Type Core Release date
2.0.0-rc1 Pre-release 11 Jul 7, 2026
8.x-1.4 Stable 8–11 Jun 21, 2026
8.x-1.3 Stable 8–11 Dec 30, 2024