A GitHub Pages compatible way of adding anchors to your headings without a plug-in or JavaScript :octocat:
The article discusses a solution for generating static heading anchors for Jekyll websites. It explains that while Jekyll websites can’t run custom plugins on GitHub pages, users can still use JavaScript solutions to inject anchors for headings. However, this may not work if users have JavaScript disabled on their browsers. As an alternative, the article presents a Liquid snippet that modifies the generated HTML to inject anchors directly. It also highlights several websites that are already using this solution.
To use this solution, follow these steps:
anchor_headings.html
file from the latest release or the master branch._includes
folder.{{/* content */}}
tag with the Liquid tag provided to output the page’s content.This article presents a solution for generating static heading anchors for Jekyll websites without relying on JavaScript. It provides a Liquid snippet that modifies the HTML output to include anchors directly. The solution is highly customizable and can be used to include a Table of Contents without JavaScript or a plugin. Developers have the flexibility to handle accessibility in their preferred way using this solution. The article also highlights several websites that are already using this approach.