使用Jekyll和Kramdown的目录 [英] Table of contents using Jekyll and Kramdown
问题描述
我试图在Jekyll网站上的页面(而不是帖子)上使用Kramdown的自动目录"生成器.
I'm trying to use Kramdown's auto "Table of Contents" generator on a page (not a post) on my Jekyll site.
_includes/toc.html
_includes/toc.html
<nav>
<h4>Table of Contents</h4>
{:toc}
</nav>
my_cool_stuff/my_cool_page.md
my_cool_stuff/my_cool_page.md
---
layout: page
---
{% include toc.html %}
# The title of my page
## The Subtitle of my page
HTML是从字面上生成的,我没有标题列表.
The HTML is generated literally and I'm not getting a list of headers.
<nav>
<h4 class="toc_title">On This Page</h4>
{:toc}
</nav>
我设置错了吗?
推荐答案
{:toc}是用于自动生成内容表的kramdown标记.
就您而言,您还需要两件事来使其正常工作:
In your case, you need two more things to make it work :
-
允许kramdown在html块内进行解析:在
_config.yml
中添加:
kramdown:
parse_block_html: true
,您需要提供一个种子列表: in _includes/toc.html
, you need to provide a seed list :<nav>
<h4>Table of Contents</h4>
* this unordered seed list will be replaced by toc as unordered list
{:toc}
</nav>
这篇关于使用Jekyll和Kramdown的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!