Table of Contents

Highlight: an allegedly simpler solution, thanks to Grant Winney: here.

Technologies

Handlebars - a templating language.

Add a TOC to your post

Firstly, add the following block in the end of your post. Warning: not in the Ghost footer. Code has been obtained from Golem.io Glarestone Theme.

<script src="https://glarestone.golem.io/assets/js/jquery-3.2.1.min.js"></script>
<script src="https://glarestone.golem.io/assets/js/jquery.sticky-kit.min.js"></script>
<script src="https://glarestone.golem.io/assets/js/jquery.ghostHunter.min.js"></script>
<script src="https://glarestone.golem.io/assets/js/glarestone.js"></script>

Finally, place the following block in the beginning of your post:

<section id="golemio-toc">
    <table class="gla-toc-wp">
        <td>Table of Contents</td>
    </table>
</section>

Create a custom post-with-TOC template

Read about Custom Page Templates.

More extensions to the Ghost default Casper theme can be found here.

Perspectives for development

The changes can be incorporated into a separate theme with help of some more knowledge.