All Projects → allejo → Jekyll Toc

allejo / Jekyll Toc

A GitHub Pages compatible Table of Contents generator without a plugin or JavaScript

Projects that are alternatives of or similar to Jekyll Toc

Alembic
⚗️ A Jekyll boilerplate theme designed to be a starting point for any Jekyll website
Stars: ✭ 501 (+63.73%)
Mutual labels:  jekyll, github-pages, liquid
Jekyll Timeline
Timeline / Résumé Theme with Jekyll
Stars: ✭ 46 (-84.97%)
Mutual labels:  jekyll, github-pages, liquid
Garth
🥁 A really basic theme for Jekyll
Stars: ✭ 85 (-72.22%)
Mutual labels:  jekyll, github-pages, liquid
fuse-core
The 'Fuse Core' Jekyll theme.
Stars: ✭ 29 (-90.52%)
Mutual labels:  jekyll, github-pages
just-the-class
A modern, highly customizable, responsive Jekyll template for course websites.
Stars: ✭ 156 (-49.02%)
Mutual labels:  github-pages, liquid
NextCommunity.github.io
Join FREE: Community of open-source programmers and software engineers.
Stars: ✭ 29 (-90.52%)
Mutual labels:  github-pages, liquid
Fastpages
An easy to use blogging platform, with enhanced support for Jupyter Notebooks.
Stars: ✭ 2,888 (+843.79%)
Mutual labels:  jekyll, github-pages
docshub
API Documentation Browser based Github Pages Service
Stars: ✭ 58 (-81.05%)
Mutual labels:  jekyll, github-pages
google-sheet-to-github-website
This is a working project for operating a data driven website on Github Pages using Google Sheets as a data source.
Stars: ✭ 20 (-93.46%)
Mutual labels:  jekyll, github-pages
harttle.github.io
Harttle Land 的源码和文章
Stars: ✭ 118 (-61.44%)
Mutual labels:  jekyll, github-pages
JekyllTheme-ProjectGaia
Jekyll Theme Project Gaia. V2 Beta Released !! Check it out ->
Stars: ✭ 110 (-64.05%)
Mutual labels:  jekyll, toc
agency-jekyll-theme
Jekyll version of the newest Agency Bootstrap theme, plus new features: Google Analytics, Markdown support, custom pages, and more!
Stars: ✭ 222 (-27.45%)
Mutual labels:  github-pages, liquid
Just The Docs
A modern, high customizable, responsive Jekyll theme for documention with built-in search.
Stars: ✭ 3,747 (+1124.51%)
Mutual labels:  jekyll, github-pages
markdownslides
A "markdown-first" approach for generating beautiful browser-based slides easily. Based on Reveal.js and Reveal-Jekyll.
Stars: ✭ 37 (-87.91%)
Mutual labels:  jekyll, github-pages
Millennial
A minimalist Jekyll theme for running an online publication
Stars: ✭ 223 (-27.12%)
Mutual labels:  jekyll, github-pages
amphp.github.io
Main website repository.
Stars: ✭ 21 (-93.14%)
Mutual labels:  jekyll, github-pages
startbootstrap-stylish-portfolio-jekyll
Jekyll theme based on Stylish Portfolio Bootstrap theme
Stars: ✭ 20 (-93.46%)
Mutual labels:  jekyll, github-pages
tactile
Tactile is a Jekyll theme for GitHub Pages
Stars: ✭ 70 (-77.12%)
Mutual labels:  jekyll, github-pages
jekyll-rest-api
Read-only REST API for Jekyll, making it easy to fetch all posts/settings in JSON for javascript search or advanced queries.
Stars: ✭ 18 (-94.12%)
Mutual labels:  jekyll, github-pages
Mm Github Pages Starter
Minimal Mistakes GitHub Pages site starter
Stars: ✭ 191 (-37.58%)
Mutual labels:  jekyll, github-pages

Jekyll Pure Liquid Table of Contents

Unit Tests Latest release ko-fi Buy me a coffee

GitHub Pages can't run custom Jekyll plug-ins so when generating Tables of Contents (TOCs), you're stuck with either a JavaScript solution or using kramdown's {:toc} option. However, by using {:toc}, you are forced to have that code next to your actual markdown and you can't place it in a layout. This means every. single. post. will need to have the snippet. If you choose the JavaScript approach, that's perfectly fine but what if JS is disabled on someone's browser or your page is just really long and it becomes inefficient.

Instead, I wrote this solution entirely in Liquid and can be used as an {% include %} in any website you want, in any layout you want. Want to see it in action? Here are some awesome websites that I know of using this solution ❤️.

For more information regarding how this include works, read the blog post.

Want anchors next to your Jekyll headings without JavaScript or a plug-in?

Check out the sister project over at allejo/jekyll-anchor-headings.

Usage

Alright, so how do you use it?

  1. Download the toc.html file from the latest release or the master branch

  2. Toss that file in your _includes folder.

  3. Use it in your template layout where you have {{ content }} which is the HTML rendered from the markdown source with this liquid tag:

    {% include toc.html html=content %}
    

Parameters

This snippet is highly customizable. Here are the available parameters to change the behavior of the snippet.

Parameter Type Default Description
html string * the HTML of compiled markdown generated by kramdown in Jekyll
sanitize bool false when set to true, the headers will be stripped of any HTML in the TOC
class string '' a CSS class assigned to the TOC; concat multiple classes with '.'
id string '' an ID to be assigned to the TOC
h_min int 1 the minimum TOC header level to use; any heading lower than this value will be ignored
h_max int 6 the maximum TOC header level to use; any heading greater than this value will be ignored
ordered bool false when set to true, an ordered list will be outputted instead of an unordered list
item_class string '' add custom class for each list item; has support for %level% placeholder, which is the current heading level
submenu_class string '' add custom class(es) for each child group of headings; has support for %level% placeholder which is the current "submenu" heading level
base_url string '' add a base url to the TOC links for when your TOC is on another page than the actual content
anchor_class string '' add custom class(es) for each anchor element
skip_no_ids bool false skip headers that do not have an id attribute

* This is a required parameter

Deprecated Variables

  • baseurl has been deprecated since 1.1.0, use base_url instead
  • skipNoIDs has been deprecated since 1.1.0, use skip_no_ids instead

Performance

The performance impact of this snippet on your site is pretty negligible. The stats below were gotten from Jekyll's --profile option.

Filename                              | Count |      Bytes |    Time
--------------------------------------+-------+------------+--------

# performance on docs.docker.com from ~Feb 2017
_includes/toc.html                    |   813 |    524.17K |  6.422

# performance on the "Minimal Mistakes" Jekyll theme
_includes/toc.html                    |    94 |     29.43K |  0.413

License

This snippet may be redistributed under either the BSD-3 or MIT licenses.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].