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:


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

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

  	.hidden-outline .toc-outline {
        display: none;
    .toc-outline {
        padding-right: .25em;