Rendering Table of Contents macro

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>
CODE

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>
CODE

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>
CODE

Cookie Notice

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 Don't track me.