Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customize automatically generated TOC on jekyll/kramdown site

I have a Jekyll site that uses kramdown for markdown. In _config.yml I have the following setting that ensures that only <h2> and <h3> elements show up in the automatically generated table of contents:

kramdown: 
  toc_levels: "2,3" 

This works fine, but on some pages I would like to include <h4> elements in the TOC as well, while retaining the existing <h2> and <h3> configuration on other pages. Is this possible?

On any page I can access the _config.yml definitions like this:

{{ site.kramdown.toc_levels }} 

Is there a way to set the value of the toc_levels on a page?

like image 685
Shailen Tuli Avatar asked Jan 02 '14 19:01

Shailen Tuli


1 Answers

I looked through the codes. It appears page-level settings are not possible for Kramdown at this moment. You are left with {:.no_toc} option to suppress unexpected tags.

like image 106
Hossain Mohd Faysal Avatar answered Sep 21 '22 00:09

Hossain Mohd Faysal