jekyll-toc
jekyll-toc copied to clipboard
Installed following the docs, but doesn't work at all
What I did
1. Add gem 'jekyll-toc'
to my gemfile.
My gemfile is very simple, looks like this:
gem "jekyll"
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
gem 'jekyll-toc'
2. Run bundle install
in the command line.
I received the message below:
Bundle complete! 3 Gemfile dependencies, 32 gems now installed.
3. Add Jekyll-toc to _config.yml.
My _config.yml file looks similar to what is shown on the Jekyll Docs:
collections:
technical-writing:
output: true
defaults:
- scope:
path: ""
type: "technical-writing"
values:
layout: "article"
- scope:
path: ""
values:
layout: "default"
plugins:
- jekyll-toc
4. Add toc: true
to my layout of a collection, and replace the {{ content }}
with {{ content | toc }}, to see if the plugin work or not.
---
layout: default
toc: true
---
<div class="container">
<div class="main contentContainer">
<div class="article">
<div class="articleNameAndMeta">
<h1>{{ page.title }}</h1>
<p>作者:{{ page.author }}</p>
</div>
<div class="articleBody">{{ content | toc }}</div>
</div>
</div>
</div>
5. Run bundle exec jekyll serve
again to rebuild the site locally.
The pages in the collection folder are completely same to previous, no table of content is added.
What is wrong?
I have read all the instructions and explanations I could find on web, including the jekyll docs and jekyll-toc readme, but it just doesn't work.
Did I do something wrong with it? Or something I missed?
Thanks!
@wongyah what jekyll version?
@msangel jekyll 4.2.0 on Win10
Following this cause same issue
Same here. The filters do nothing at all.
⚠️ {% toc %} Tag Limitation
{% toc %}
works only for Jekyll Posts and Jekyll Collections. If you'd like to use{% toc %}
exceptposts
orcollections
, please use toc_only filter as described below.
- 中文: 请允许我用中文给大家说明:如果不是
_posts/*.md
或者_**/*.md
(合集),比如about.md
;只能使用{{ content | toc_only }}
- english: If it is not
_posts/*.md
or_**/*.md
(collection), such asabout.md
; you must only use{{ content | toc_only }}
- Method One:
{% toc %}
- Method Two:
{{ content | toc_only }}