by Jonathan Rothwell

[LINK] Easy tables-of-contents in Octopress

In an attempt to clean up the Doctor Who guide, I discovered Robert Reimann’s excellent post to using kramdown’s HTML converter to achieve tables of contents in Octopress. (This blog, in its current incarnation, has pretty much always used kramdown—it’s how I do footnotes.)

Ultimately, I needed around five lines of code and a little bit of fiddling with the source file to get it to work.1 It was exceptionally easy. The biggest fuss was the styling. If you’re looking to implement a table of contents in your Octopress site—or any static site that uses kramdown as its generator—this is the method you should use.

  1. A lot of the guide is still copy-and-pasted from my old site, and was raw HTML: my understanding is that kramdown will not generate header IDs, and therefore anchor tags, unless the header was in Markdown as opposed to being in pure HTML.