Is Github Pages not supported?
Oddly, on Github Pages, it doesn't work. When I deployed Github Pages to Vercel simultaneously, it worked. Now, if you open the Github Pages page, there is no TOC, but if you open the Vercel page, there is TOC.
It's been a long while since, but hopefully this helps someone else too
"GitHub Pages cannot build sites using unsupported plugins. If you want to use unsupported plugins, generate your site locally and then push your site's static files to GitHub."
What I've done to use jekyll-toc is that I built locally and deployed on a separate branch with the _site directory as root, it's funky but works perfectly!
With GitHub Actions builds in Pages now, this works if you deploy using an actions workflow (e.g. the Jekyll template workflow).
Here is a very simple solution: allejo/jekyll-toc
Another solution is through generating the site's static files and pushing them to Github: Use jekyll-toc plugin on Github Pages posted by David Dong.