I recently wanted to add a table of contents to a post in Jekyll, but I didn’t really want to create it by hand. Thankfully there is a way to insert a dynamic table of contents into a post:

* Table of Contents
{:toc}

The line that starts with * is required but will not be displayed. The above markup will generate a table of contents that links to each header within the post.

You can see an example here.