×

You're using an outdated browser

For a better experience, keep your browser up to date. Check here for the latest version.

Manual

Rendering Table of Contents macro

Thomas Walker

Thomas Walker Last update: Oct 17, 2017

In Confluence versions 5.8 and later, Table of Contents macros are no longer rendered server-side anymore – meaning that we have to include a few resources in order to create a TOC.

In your head, include these resources:

<head>
	$page.resources.css
	$page.resources.js
	$page.resources.meta
	$page.resources.require('org.randombits.confluence.toc:client-side-toc-resources')
</head>

Tip

For this to work, the script looks for all headings within an HTML element with the id "main-content". So make sure, that the element that wraps $page.content will have the ID.

<div id="main-content">
	$page.content
</div>

You can add the following style to clean up the clutter generated by the macro for Viewport.

<style>
  	.hidden-outline .toc-outline {
        display: none;
    }
    .toc-outline {
        padding-right: .25em;
    }
</style>
2x2.10
We use cookies to create a secure and effective browsing experience for our website visitors and to understand how you use our site (i.e. Google Analytics). For more information: click here.
Ok