Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wongyah opened this issue Jun 17, 2021 · 5 comments
Open

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

wongyah opened this issue Jun 17, 2021 · 5 comments

Comments

@wongyah
Copy link

wongyah commented Jun 17, 2021

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
Copy link

msangel commented Jul 5, 2021

@wongyah what jekyll version?

@wongyah
Copy link
Author

wongyah commented Jul 6, 2021

@msangel jekyll 4.2.0 on Win10

@donaldpiret
Copy link

Following this cause same issue

@starikcetin
Copy link

Same here. The filters do nothing at all.

@y377
Copy link

y377 commented Oct 27, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants