Is it possible to generate a table of contents using kramdown in a page other than a post? If so, how?

百般思念 提交于 2019-12-04 11:19:37

If your index page doesn't have YAML front-matter, then Jekyll won't invoke the kramdown processor. It's a guess but this could be your problem.

There's no way to do this with a kramdown option nor can you use the {:toc} option with the {{ content }} of a Jekyll page because {:toc} won't work with generated HTML.

I realize this is an older question, but for anyone who stumbles upon this question more recently. I wrote up a solution to this problem here that uses only Liquid so it'll run perfectly fine on GitHub pages (no plug-in involved) and with JavaScript disabled. My solution works with the generated HTML given by Jekyll so there's no need for wonky work arounds.

I also realize "link only answers" are frowned upon, but I'd rather not have to maintain the same code snippet in multiple places. So I hope you don't mind.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!