15

Is there a way to generate a ToC on a rendered README.md hosted on Github Pages that doesn't require the use of local Jekyll plugins to generate it prior to uploading it to Github Pages?

Damjan Pavlica
  • 31,277
  • 10
  • 71
  • 76
orschiro
  • 19,847
  • 19
  • 64
  • 95

2 Answers2

13

According to this post, all you have to do is add {:toc} in your markdown page at the place you want a table of contents.

Adrian J. Moreno
  • 14,350
  • 1
  • 37
  • 44
  • 3
    Thanks! Actually, you need to add `* TOC {:toc}` once you added `markdown: kramdown` to your `_config.yml`. – orschiro Jan 17 '19 at 21:11
  • 3
    Still not working. Can you link your repo where it works? – PeterT Mar 09 '21 at 17:33
  • 1
    We need to insert a new line to let TOC be rendered `* Placeholder for Table of Content (Must not be removed) {:toc}` – Sunfarm Aug 03 '21 at 17:28
-1

You have to wrap the ToC contents between TOC and /TOC fields in the README.md file.

Sush
  • 1
  • 2