How to create a table of contents to Jekyll blog post?

前端 未结 6 861
不思量自难忘°
不思量自难忘° 2020-12-04 21:30

If I have a page/post in Jekyll with headers, is it possible to auto-generate a table-of-contents/outline for navigation? Something akin to the top matter of a Wikipedia art

6条回答
  •  抹茶落季
    2020-12-04 22:15

    I'm assuming you mean a list of all H1, H2 elements etc in the content itself? I don't think Jekyll has anything built-in to handle that. I suspect the easiest way is to let Javascript generate it for you once the page has rendered, using something like this jQuery plugin, or one of the many other plugins/snippets available.

提交回复
热议问题