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.

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:

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.