jekyll-toc icon indicating copy to clipboard operation
jekyll-toc copied to clipboard

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

Open wongyah opened this issue 3 years ago • 5 comments

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 avatar Jun 17 '21 07:06 wongyah

@wongyah what jekyll version?

msangel avatar Jul 05 '21 19:07 msangel

@msangel jekyll 4.2.0 on Win10

wongyah avatar Jul 06 '21 02:07 wongyah

Following this cause same issue

donaldpiret avatar Aug 10 '21 07:08 donaldpiret

Same here. The filters do nothing at all.

starikcetin avatar Jul 26 '23 18:07 starikcetin

⚠️ {% 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.


  • 中文: 请允许我用中文给大家说明:如果不是_posts/*.md或者_**/*.md(合集),比如about.md;只能使用{{ content | toc_only }}
  • english: If it is not _posts/*.md or _**/*.md (collection), such as about.md; you must only use {{ content | toc_only }}
  1. Method One:{% toc %}
  2. Method Two:{{ content | toc_only }}

y377 avatar Oct 27 '23 12:10 y377