-
Notifications
You must be signed in to change notification settings - Fork 25.6k
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
Toggle table of contents via front matter #1222
Comments
I don't think there is any way to do this. The
There's probably a Jekyll plugin you could leverage to do it, but that wouldn't happen at the theme level. |
Might I recommend a solution like this? https://github.com/allejo/jekyll-toc This'll take the generated HTML from the markdown and generate a TOC from that and can be used from inside a layout. It's also written in Liquid, so it's compatible with GH pages since it's not a plug-in and doesn't require JS. |
Good solution @allejo, I've recommended it before for those who want some more flexibility over what Kramdown's auto TOC or JS solutions provide. Do you have any stats around the impact of using this include across a ton of post's? Have to think with it looping over all the content to pull out the headings there'll be a hit in |
Haven't really done any extensive testing for stats. Got any suggestions for tests I should do? The only stat I have is for the Docker docs site (through Edit: Just ran |
I have a fairly large site myself, when I get a chance I'll give it a test just to compare against. |
Oh sweet, I'd definitely be interested in seeing how it performs on your site 👍 |
Did some quick tests using the sample posts in this theme and I didn't really see any impact on build time.
Which is very encouraging. Seems like a valid replacement to me. There's probably a few second hit on a site with hundreds/thousands of posts, but I'm cool with that. @vahid-dan Looks like what you want to do is something I can bake into the theme. Thinking something like If I ditch the Kramdown auto-generated TOC it frees me up to move it somewhere more semantic in the HTML layouts too. |
This feature has been added to the theme. Haven't pushed a new theme gem version yet, but the updates are all on I've kept the old Kramdown based method in for now, but plan on removing that in the next version. To enable table of contents on pages using the The icon and label title can both be changed per page just like with the old version. ---
toc: true
toc_label: "My Custom Table of Contents Label"
toc_icon: "gear"
--- TOC's can also be set globally for entire section of pages/posts using Front Matter defaults in |
Hopefully someone can assist... |
* Add jekyll-toc include * Reduce whitespace generated by comments * Add table of contents include to `single` layout * Replace `toc` include with jekyll-toc enabled YAML Front Matter * Update README * Update table of contents documentation - Revise `toc` helper include to mention that it will be deprecated in the next major version. - Add documentation to `single` layout explaining how to enable table of contents on those pages. * Update CHANGELOG and history * Update LICENSE Close mmistakes#1222
* Add jekyll-toc include * Reduce whitespace generated by comments * Add table of contents include to `single` layout * Replace `toc` include with jekyll-toc enabled YAML Front Matter * Update README * Update table of contents documentation - Revise `toc` helper include to mention that it will be deprecated in the next major version. - Add documentation to `single` layout explaining how to enable table of contents on those pages. * Update CHANGELOG and history * Update LICENSE Close mmistakes#1222
* Add jekyll-toc include * Reduce whitespace generated by comments * Add table of contents include to `single` layout * Replace `toc` include with jekyll-toc enabled YAML Front Matter * Update README * Update table of contents documentation - Revise `toc` helper include to mention that it will be deprecated in the next major version. - Add documentation to `single` layout explaining how to enable table of contents on those pages. * Update CHANGELOG and history * Update LICENSE Close mmistakes#1222
* docs(tutorials): add social options settings * docs: update features in README
bundle update
.bundle exec jekyll build
.Environment information
Expected behavior
I have imported GitHub wiki pages as a submodule into the Jekyll website. Now I want to automatically add "Table of Contents" to every wiki page without having to add
{% include toc %}
manually to every page. Wiki pages inside the website are in thewiki
directory and havewiki.html
layout.The text was updated successfully, but these errors were encountered: