How to create a table of contents to Jekyll blog post?

Zando picture Zando · Mar 7, 2012 · Viewed 8.1k times · Source

If I have a page/post in Jekyll with headers, is it possible to auto-generate a table-of-contents/outline for navigation? Something akin to the top matter of a Wikipedia article.

Answer

manatwork picture manatwork · Mar 8, 2012

That is the markup parser's task.

In case of Markdown one of the syntax extensions defines Automatic generation of the table of contents:

* This will become a table of contents (this text will be scrapped).
{:toc}

This works in Maruku and kramdown.