Jekyll's Plugins page mentions a plugin jekyll-toc-generator, but there is no need to use plug-ins because Jekyll markdown renderer Kramdown already has this feature. We just need to enable it.
Enable kramdown#
Open the _config.yml file to ensure that the following line exists:
Markdown:kramdown
Generate toc#
The next step is to identify the build location of the TOC in the article:
* Catalogue
{: TOC}
# Chen San
# # Chen San's Blog
Please note that the * directory is a required line that represents a list of trees, please feel free to write what's behind the asterisk
If you want to exclude a title from the tree, write {:. No_toc} on the next line of the heading
The depth of the directory can be customized by adding the Toc_levels option to the Config.yml file, which defaults to 1..6, which indicates that title one to title six is all rendered
{: TOC} The list of directories generated by default will add ID value Markdown-toc, we can customize the ID value, such as {: TOC #chenxsan}, the generated directory list added ID will be chenxsan.