subtopic-[Slug]
.href="#subtopic-[Slug]"
using dynamic data.To create scroll-to-subtopic buttons on a CMS page in Webflow, each button must link to an anchor ID that corresponds to a dynamically generated topic within a Collection List. Here's how to do it:
subtopic-[Slug]
.Slug
or Anchor ID
from the CMS collection.introduction
, the element ID should be subtopic-introduction
.#subtopic-introduction
body
elementtag to offset anchor scrolling using JavaScript (Webflow doesn’t natively offset anchors).
Example inline code:
<script> document.querySelectorAll('a[href^="#subtopic-"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); const offset = 80; // height of your nav const target = document.querySelector(this.getAttribute('href')); window.scrollTo({ top: target.offsetTop - offset, behavior: 'smooth' }); }); });</script>
To create scroll-to-subtopic buttons on a CMS page in Webflow:
subtopic-[Slug]
).href="#subtopic-[Slug]"
.This setup ensures that each button scrolls smoothly to its corresponding dynamic subtopic.