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

Table of contents for page sections #72

Open
Tora-B opened this issue Jun 16, 2018 · 4 comments
Open

Table of contents for page sections #72

Tora-B opened this issue Jun 16, 2018 · 4 comments

Comments

@Tora-B
Copy link

Tora-B commented Jun 16, 2018

I often go to pages on a machine specifically looking for what augments they accept, or to look at the recipes, and it can be a lot of scrolling or guessing to hit the right section on the page. The sections already have anchors, and it would be really convenient to have a table of contents to quickly jump to them. I would suggest either a horizontal list near the top of the page, perhaps right underneath the page title, or a floating box on the side.

@Tonius
Copy link
Member

Tonius commented Jun 18, 2018

Note to self: this might be useful for generating this automatically

https://kramdown.gettalong.org/converter/html.html#toc

@sustained
Copy link

I also would really like this.

I'll look into implementing it but first I'm working on some other things.

@sustained
Copy link

sustained commented Jul 4, 2019

I tried adding this feature just now but I had issues getting it working how I would have liked with both methods (jekyll-toc and kramdown).

I could submit a PR that implements it in the following way but that is not ideal (i.e. at the top of each page):

image

I would rather it be a sidebar, like the links on the homepage.

Basically the issue is that neither{% toc %} nor {:toc} will work if they are in an include or layout.

@Tonius Thoughts?

@Tonius
Copy link
Member

Tonius commented Jul 4, 2019

jekyll-toc is not provided by GitHub Pages, so only {:toc} remains. (I just saw jekyll-toc can just be added as an include)

My idea was to make it similar to the tables of contents found on wikis (example). It would be a block with slightly smaller text, possibly with a button to hide it.

Also like wikis, I would like it to come after the first block of text and before the first subheader of a page. So putting it in a layout wouldn't really work anyway IMO. Unless the first block of text is put in the front matter, which I personally am not a fan of because it makes the pages harder to read in raw Markdown form.

I can think of two other methods to generate tables of contents:

  • writing some custom JavaScript;
  • writing an include that renders a table of contents and manually passing some YAML to it on each page (or only on pages that need it).

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

No branches or pull requests

3 participants