toshimaru / jekyll-toc

Jekyll plugin which generates a table of contents.
MIT License
340 stars 52 forks source link

Installed following the docs, but doesn't work at all #147

Open wongyah opened 3 years ago

wongyah commented 3 years ago

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!

msangel commented 3 years ago

@wongyah what jekyll version?

wongyah commented 3 years ago

@msangel jekyll 4.2.0 on Win10

donaldpiret commented 3 years ago

Following this cause same issue

starikcetin commented 1 year ago

Same here. The filters do nothing at all.

y377 commented 11 months ago

⚠️ {% toc %} Tag Limitation {% toc %} works only for Jekyll Posts and Jekyll Collections. If you'd like to use {% toc %}except posts or collections, please use toc_only filter as described below.


  1. Method One:{% toc %}
  2. Method Two:{{ content | toc_only }}