Docs & Table of Contents Pro

An auto-generating, sticky table of contents that builds itself from your page headings — no manual anchor tagging, ever. Scroll-spy active highlighting, deep linking with sticky-header offsets, an optional multi-page documentation sidebar, and JSON-LD structured data baked in. Every pixel styled from the editor. Vanilla JS, zero jQuery.

Auto-generates anchors Scroll-spy highlighting Works with sticky headers Handles duplicate headings TechArticle / FAQPage JSON-LD 3 layouts WCAG AA
Live module

One module: Docs, FAQ & Contact

Below is a single module instance — nothing on it is hand-coded. Switch between Docs, FAQ and Contact from the left without leaving the page; each section builds its own table of contents from its headings, deep-links update the URL, and the Contact section holds the form. Default look is a clean monochrome UI — every value is editable.

A practical, end-to-end guide to headless commerce — the architecture, the trade-offs, and a migration path you can actually ship. Everything on this page, including this article and the table of contents, is rendered by the module from its own fields.

Getting started with headless commerce

Headless commerce decouples the storefront presentation layer from the commerce engine, letting teams ship front-end experiences independently of the back end. Instead of one monolith owning templates, business logic and data, you get a commerce API on one side and a framework of your choosing on the other.

Who this is for

Engineering leads weighing a re-platform, and marketing teams tired of waiting on a release window to change a hero image.

What you’ll need

  • A commerce engine with a usable API
  • A front-end framework (Next.js, Nuxt, Astro, SvelteKit)
  • A content layer for everything that isn’t a product

Watch the 90-second overview

A quick visual tour before we dig into the architecture:

Why teams move to a headless architecture

The pressure usually comes from the front end. Marketing wants to ship campaigns without a developer in the loop, and engineering wants a modern framework without forking the commerce platform.

Performance and Core Web Vitals

Static- or edge-rendered storefronts routinely cut Largest Contentful Paint in half versus server-rendered monoliths. Faster pages convert better and rank better.

Channel reuse

The same commerce API powers the web storefront, the mobile app, in-store kiosks and partner marketplaces without duplicating business logic.

The core building blocks

A headless stack has four moving parts. Understanding the seam between each one is the whole game:

  • Commerce engine — catalog, cart, pricing, promotions, checkout, orders.
  • Presentation layer — the framework consuming the API.
  • Content layer — a headless CMS for merchandising and editorial.
  • Edge/CDN — where rendered pages are cached and served.

Choosing your rendering strategy

Static generation, server-side rendering, incremental static regeneration (ISR) and edge rendering each have a place. Catalog pages favour ISR; account pages require SSR; marketing pages are happiest static.

Pick the cheapest rendering mode that still tells the truth. Everything else is a caching problem.

Caching at the edge

Pushing rendered HTML to a CDN edge is the single biggest performance lever. Cache invalidation on price and inventory changes is the hard part — budget real engineering time for it.

Designing the commerce API layer

Wrap the engine in a thin gateway so the storefront depends on your contract, not the vendor’s. A typical product query:

GET /api/products/:handle
{
  "id": "SKU-1042",
  "title": "Merino Crew",
  "price": { "amount": 8900, "currency": "USD" },
  "availability": "in_stock"
}

Keep money in minor units, never floats, and let the gateway normalise vendor responses.

Planning the migration

Big-bang rewrites fail. The strangler-fig pattern lets you ship value in weeks instead of quarters:

  1. Migrate the highest-traffic template first (the product detail page).
  2. Expand template by template, measuring as you go.
  3. Keep checkout last — it carries the most payment and regulatory risk.

Measuring success after launch

Track four numbers: conversion rate, Core Web Vitals at the 75th percentile, time-to-publish for marketing, and deploy frequency for engineering. If those move in the right direction, the migration paid for itself.

Common pitfalls to avoid

  • Underestimating the content layer and bolting it on late.
  • Treating SEO and structured data as an afterthought.
  • Forgetting that someone now operates two systems instead of one.

Is headless always the answer?

No. A poorly cached headless storefront can be slower than a well-tuned monolith, and it always costs more to operate. Choose it when independent release cadences and multi-channel reuse genuinely pay for the added complexity.


Documentation

Module Guide

Everything you need to set it up, plus the rules that keep it working on messy real-world pages.

What it does

Docs & Table of Contents Pro builds a table of contents automatically from the headings already on your page — you never hand-tag anchors. On render it scans your content, generates a URL-safe id on every heading (without ever overwriting an existing one), and builds a navigable, scroll-spy TOC that highlights the section the reader is currently viewing. It also ships an optional multi-page documentation sidebar and outputs JSON-LD structured data so search engines and AI assistants can understand and cite your sections. Vanilla JS, no jQuery, no external libraries.

Quick setup

  1. Drop the module onto any page, blog post, or template — ideally in the column next to your article (Right Rail), in a left column (Sidebar Left), or in a full-width row above the content (Top Bar).
  2. Pick a layout under Content > Layout. Right Rail is the default.
  3. Leave Content Scope blank to auto-detect your main content, or paste a CSS selector to target a specific container (see below).
  4. Set the Scroll Target Offset (Style > Layout Controls) to clear any sticky site header — this is the #1 thing to get right (see Sticky headers).

That's it. Sensible defaults mean it looks good and works the instant it's dropped on a page, before any configuration.

How auto-generation works

On load (and again after the page fully loads), the module scans the content scope for headings, then:

If zero headings are found, the module renders nothing on the live page — no empty broken box. Inside the HubSpot editor it shows a sample preview so you know it's working.

Content scope

The Content Scope field (Content > Behavior & Detection) controls which part of the page is scanned.

Heading levels

Choose which levels to include: H2 only, H2 and H3, or H2, H3 and H4. Nested levels are indented to show document hierarchy.

Layouts

Sticky headers (the offset rule)

Two offsets live under Style > Layout Controls:

Tip: set the Scroll Target Offset to roughly your sticky header height + 16px. If a heading lands hidden under your navbar, this is the value to raise.

Active highlighting & deep linking

Filter / search box

An optional live filter (Content > Show Filter / Search Box) narrows the table of contents — and the multi-page nav — as the reader types. It is fully styleable under Style > Filter / Search Box: background, text, placeholder, border, icon and focus-ring colors, font, border radius, vertical padding, and a show/hide-icon toggle.

Help / contact box

Turn on Content > Help / Contact CTA to add a "Still have questions?" card at the bottom of the TOC panel — the standard docs pattern. Pick a HubSpot form to embed it inline (styled to match your module settings — inputs, labels, focus ring, and submit button all themed), or leave the form empty to show a contact button instead. Fully styleable under Style > Help / Contact Card (background, border, heading/text colors, button colors, radius). Hidden automatically in the Top Bar layout.

Multi-page navigation

Enable Content > Multi-Page Navigation to add a persistent list of doc pages above the on-this-page TOC (best with the Sidebar Left layout). Each row is a link with an optional group heading.

JSON-LD structured data

When headings are found, the module emits a <script type="application/ld+json"> block describing the page's section structure — built from the headings actually detected, so it always matches what's on the page. Choose the type under Content > SEO / Structured Data:

Example output (TechArticle)

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "TechArticle",
  "headline": "Getting started with headless commerce",
  "url": "https://example.com/guide",
  "hasPart": [
    { "@type": "WebPageElement", "name": "Why teams move to headless",
      "url": "https://example.com/guide#why-teams-move-to-headless" }
  ]
}
</script>

The module only emits schema when there are headings to describe, never empty or malformed. Turn it off under SEO / Structured Data if you manage schema elsewhere.

Mobile behaviour

Below the configurable breakpoint (Style > Responsive), the TOC switches to:

The Top Bar always collapses to a sheet on mobile.

Style controls

Typography (per level)

Dedicated HubSpot font fields for the TOC title, top-level items, nested items, and the active item — family, weight, size and color in one control. Plus text-transform per level, title letter-spacing, and item line-height.

Colors

Container background and border, hover text and background, active background, active-indicator color, and the reading-progress bar fill + track — all with opacity.

Active indicator

Left border bar (with adjustable thickness), filled background, dot marker, bold weight only, or none.

Filter / Search Box

Background, text, placeholder, border, icon, focus colors; font; radius; padding; show/hide icon.

Spacing & shape

Container padding, item vertical/horizontal padding, indent per nesting level, container border width and radius, item radius, and an optional container shadow (off by default).

Layout controls

Width (rail/sidebar), gap to content, sticky top offset, scroll target offset, max height with internal scroll for very long pages, and top-bar inner max width.

Responsive

The mobile breakpoint at which the layout switches to its mobile behaviour.

Accessibility

Troubleshooting & rules

About this demo

This page shows the default Sticky Right Rail layout against one comprehensive article: auto-generated anchors, scroll-spy highlighting, the filter box, deep linking (click an entry and watch the URL hash), the reading-progress bar, an embedded contact form, and TechArticle JSON-LD — all from default "cool UI" styling (left-bar indicator, indigo accent, Inter). The Sidebar Left and Top Bar layouts described above are the same engine with a different layout setting.