This tutorial provides the steps to create a Table of contents using TOCbot.js in HTML and in WordPress similar to what we have now on this tutorial at the sidebar.
Prerequisite:
The Headings should have an id to build a Table of contents using the TOCbot script. You can add the Heading id manually or using some script.