I played around with the Drupal "Book" core module for a while. But found it wasn't quite what I wanted. Here's a simple approach for building a section of pages with a table-of-contents that did work for me...

Setup:

  • Create a new menu for the table of contents. (Structure >> Menus)
     
  • To create section headings that do not link to pages, add a menu link with Link set to: route:<nolink> (notice there's no space after the colon!) Also, select the "Show as expanded" checkbox.

no-link-menu-link-example-1

  • Create a new content type (Structure >> Content types), and select the new menu in "Menu settings".
     
  • Use Structure >> Block Layouts to place the new menu in the left or right sidebar region:
    • The Title will display as a title for the table of contents menu.
    • Menu Levels: initial visibility level 1 and unlimited number of levels.
    • Visiblity: limit Content types to the new content type.

Now just add the content, building the menu as you go...

For each page added, select, "Provide a menu link" in Menu Settings. Select the menu parent and weight to build the table of contents. Note: if any pages have subsection pages, you may want/need to go back to Structure>>Menus to edit their menus and select the "Show as expanded" checkbox.

Here's an example of a finished table-of-contents menu:

TOC_menu-1