How to add an automatic table of content (TOC) to blog post in wix

In wix blog i wish to add an automatic table of content (toc) of Headings and SubHeadings so as to make my blog readable. Here are few examples

(1) https://help.wixanswers. com/kb/en/article/getting-started-with-your-knowledge-base-articles (left sidebar)
(2) https://advanced-js.github. io/syllabus/ (right sidebar)

The second one also provides the javascript code that enables this (https://www.jqueryscript. net/menu/Sidebar-Table-Of-Contents-Generator-with-jQuery-and-Bootstrap-Bootstrap-Toc.html)

Is it possible to put this above javascript code into the wix blog post so that a sidebar can be used to automatically generate a table of content based on the headings/subheadings of the blog post ? If so can someone show me how?

Thanks
SP

Hello from the Wix DevRel Team!

I don’t think there’s any way to reuse the jQuery code that you’ve linked above, but you can easily write something similar using Velo’s children method within the Page API. You should be able to write a function that loops through the children elements after the page has loaded and populates the sidebar based on the parameters you’re looking for (in this case, headers of a certain type, probably h2 or h3).

Hope this helps!

Rob

Hi, thanks. I wish i knew how :slight_smile: If you know how to do this then please share some code sample that i can use. Please email me or DM me if you can help me with this. Appreciate it.

Make NOT SENSE at all… in the year 2023 still WIX has no way to make a table of contents unless you make the anchor text ONE BY ONE… please update.

1 Like

Completely agree! The blog feature is stuck in the stone age! Considering moving to wordpress to gain more autonomy over my page. Wix blog looks so ugly compared to others! Frustrated.

1 Like