Set up automatically generated TOC on jekyll / kramdown

I have a Jekyll website that uses kramdown for markdowns. In _config.yml , I have the following parameter, which ensures that only the <h2> and <h3> elements are displayed in the automatically generated table of contents:

 kramdown: toc_levels: "2,3" 

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

On any page, I can access _config.yml definitions as follows:

 {{ site.kramdown.toc_levels }} 

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

+8
jekyll liquid kramdown
source share
1 answer

I looked through the codes. Currently, Kramdown cannot set page-level options. You have the {: .no_toc} option to suppress unexpected tags.

+5
source share

All Articles