[TUTORIAL] Dynamic Table of Contents on Webflow CMS (no plugins, automatic)

Hey, is it possible to make the ToC in an ordered list?

1 Like

@aaro This is great thanks for putting this together., one question how can I go in to offset the Y-axis scroll?

Right now when I click on the ToC Items the site scrolls past the H2 for me.

Hereā€™s a link to the inprogress blog post

1 Like

Hey Sam :wave: Debugging stuff like this can get complicatedā€¦ if itā€™s not too late, I recommend cloning the project above and copying the required components into your site. If you test it each time you make a change, I guarantee youā€™ll get to the finish line. Good luck!

Iā€™ve had this same issue. Checkout these posts for solutionsā€¦

@aaro Hey Aaro, love this tutorial! , but having a really weird issue with h2, h3, &h4 classes on a duplicate CMS template - an exact duplicateā€¦

The first CMS collection works as expectedā€¦

But the second CMS collection does thisā€¦

It look like the observer is not adding/replacing the class?? Any suggestions or ideas?

Read only link

Good CMS collection link

Problem CMS collection link

Iā€™m stumped, someone help please :pray:

@DuncanHamra Your solution is great! The only issue I have is that it doesnā€™t have the logic or classes to indent the ToC items based on Heading size like the Flowrite example. Is there a good reason you didnā€™t implement this? I ask because Iā€™m having issues with the original implementation, but only on 1 pageā€¦ I posted my issue :point_up_2: :thinking:

1 Like

I went with the more simple implementation for the sake of speed/ease of use. For that reason, I think I left out some code that was required for the more complex setupā€¦ although Iā€™m sorry to say I donā€™t remember which code :disappointed: This week is pretty crazy, so I donā€™t be able to dedicate much time here

image

1 Like

Hi and thanks for making it clonable

sorry for that question but how did you paste your code in webflow?

1 Like

Is their a way to generate the same table twice on the sampage?

1 Like

Is their a way to generate same table twice?

1 Like

I have a question, first things first. Great implementation, this feature was a great added value to our website, thank you!

My question now, how can I increase the offset in the anchor when I click in a heading from the table of contents and the page is scrolled to that element? I ask that because I have a sticky header, and when I click in a heading from the blog, it is not showing because it is under the sticky header.

Cheers.

1 Like

Great question! The easiest way that I have found is to:

  1. Select one of your blog headings that you want to be an anchor.
  2. Give that element some top padding equal to the height of your sticky nav. Letā€™s say 100px for the sake of example.
  3. And also give it a negative margin of 100px.

This will move the top of the element 100px up the page while not disrupting your spacing.

Publish and youā€™re good to go!

Sorry I missed your question! Iā€™m not sure how to generate the same table twice. I feel confident it can be done by a developer, but Iā€™m not sure how to do it myself.

This tuto is just brillant ! A little complicated at first but the result is perfect.
I have a question about the links that are created with this table of contents, does Google index them and how to manage them from an SEO point of view?
Thanks a lot

1 Like

@Melanie12 - Google does not index named anchor links since they are only relative to the page and are not internal nor external links. They are factored (the headings) in the on-page SEO and may at Googleā€™s discretion show up in the SERP snippet when used in a table of contents scenario if it is relevant.

2 Likes

Thanks for your reply @webdev . Iā€™ve waited a while and now Iā€™ve got lots of urls of this type in my search console.
I donā€™t know how to deal with the problem.