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

TOC generated only on selected posts #74

Closed
edoardottt opened this issue Nov 6, 2024 · 3 comments
Closed

TOC generated only on selected posts #74

edoardottt opened this issue Nov 6, 2024 · 3 comments
Labels
wontfix This will not be worked on

Comments

@edoardottt
Copy link

Description

With https://github.com/toshimaru/jekyll-toc (that as now it doesn't work for GitHub Pages) it's possible to add a selector in the post settings and select for which posts the table of contents must be shown.

Sample Usage

e.g.

---
published: true
title: example title
layout: post
tags:
  - example
categories:
  - example
permalink: example
toc: true
---

It's possible to define toc: true/false to decide in the post markdown content if the TOC should be generated or not.

As far as I know this isn't working for this repository.

Expected TOC

  • toc: true: HTML TOC generated
  • toc: false: HTML TOC not generated
@edoardottt edoardottt added the enhancement New feature or request label Nov 6, 2024
@allejo
Copy link
Owner

allejo commented Nov 6, 2024

This project has nothing to do with the YAML frontmatter and only works with the Jekyll-generated HTML. What you can do in your theme though is, if the toc frontmatter is true, give the heading the ".no_toc" class (as per #21), and that heading will be excluded from the generated TOC.

@allejo allejo closed this as not planned Won't fix, can't repro, duplicate, stale Nov 6, 2024
@allejo allejo added wontfix This will not be worked on and removed enhancement New feature or request labels Nov 6, 2024
@edoardottt
Copy link
Author

Thanks @allejo for the quick reply and sorry for misunderstanding!

I'm new to jekyll, sorry again. What do you mean with in your theme ?
I guess something like this (using CSS selectors for markdown):

### Heading3
{: .no-toc }

If this is the case it won't be good as I need the TOC only for 1 post and ignore it for all the others.
Adding a class for all the headings in all other posts won't be easy.
That's why I mentioned the YAML frontmatter selector.

@allejo
Copy link
Owner

allejo commented Nov 14, 2024

Take a look at the Minimal Mistakes Jekyll theme, which makes use of this project. If you put toc: false in your front matter, you can access that from your Liquid templates via page.toc like so,

https://github.com/mmistakes/minimal-mistakes/blob/6f5e6f43911c0283bd029040a4b22d3d31fe3c30/_layouts/single.html#L42-L53

Based on whether or not that variable is set, that's where you can choose to include the toc.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants