Jekyll table of contents
Mon, Mar 14, 2016 · 2 minute readpowershelljekyll
Portable Jekyll
Wish I’d found this link before actually installing Jekyll.
More details here.
Powershell and jekyll
Some Powershell functions for interacting with jekyll.
Could maybe use some more work as they are a year old at time of writing.
Table Of Contents
Simple way to create a table of contents (TOC) for your post is to include these two lines after the frontmatter:
* TOC
{:toc}
The TOC is just a placeholder and will be replaced with an unordered list taken from the post headings.
The list can be controlled by settings in _config.yml
auto_ids, obvious enough, headings will get automatically created ID’s.
toc_levels, include only headings in the specified range.
In my experience, the generated TOC will not appear in a post excerpt (using post.excerpt),
unless the TOC is changed to something like this:
* TOC
{:toc}
<!--more-->
You can then use the following in your index page to read the TOC:
{% raw %}
{% for post in site.posts %}
{% assign post_url = post.url | append:‘#’ %}
{{ post.content | split: site.excerpt_separator| first | replace:‘#’,post_url }}
{% endfor %}
{% endraw %}
Note that, on the index page the TOC is generated with the current, i.e root, page URL.
The replace above corrects that by inserting the post URL.