Child pages
  • Table of Contents Macro
Skip to end of metadata
Go to start of metadata

The Table of Contents macro scans the headings of the current Confluence page to dynamically create a table of contents from your page headings. This helps you navigate lengthy pages by summarising the content structure and providing links to headings. Headings are indented progressively.

On this page:

Usage with the Rich Text Editor

1. From the Rich Text Editor toolbar, select Insert, then select Table of Contents from the drop-down menu.
2. From the 'Insert 'Table of Contents' Macro' dialog box, select the required parameter values, then click 'insert' to add the table of contents to your page.

Usage with the Macro Browser

To insert the 'Table of Contents' macro into a page using the Macro Browser,

  1. Open the Confluence page or blog post that you want to edit, then click the 'Edit' button.
  2. Click the Macro Browser icon on the toolbar. The macro browser window will open.
  3. Scroll through the list of macros to find the one you want. Alternatively, start typing the macro name into the search box at the top right of the macro browser. Macros with a matching name will appear in the main pane.
  4. Click the desired macro.
  5. Set the macro parameters to your requirements. If desired, you can preview these changes by clicking 'Refresh'.
  6. Click 'Insert' to add the macro onto the page.

(tick) You can also insert macros via autocomplete. For more information, see Using Autocomplete in the Rich Text Editor.

Once you've found the table of contents macro and have added the required parameter values, click 'insert' to add it to your page.

Usage with the Wiki Markup Editor

Include the following markup in your page:

{toc:type={[list,flat]|outline=[true,false]|style=[circle,square,disc,decimal,lower-roman]|indent=[5px]|minLevel=1|maxLevel=3}

There are more examples below.

Macro Parameters

Parameters are options that you can include in Confluence macros to control the content or format of the macro output. The table below lists relevant parameters for this macro.

Parameter names are different in the macro browser and in wiki markup. Below we show the macro browser parameter names in bold text, and the equivalent wiki markup parameters in (bracketed) text. If we do not show any parameter name for the wiki markup, then you should leave out the parameter name and simply include the parameter value as the first parameter, immediately after the colon (:).

Parameter

Required?

Default

Description

Output Type
(type)

no

list

Set this to "list" or "flat".  Selecting list produces a typical list type TOC.  Selecting flat produces a horizontal menu-type series of links, for example: [Heading 1] [Heading 2] [Heading 3].

Display Section Numbering
(outline)

no

false

Select the tick box to apply outline numbering to your headings, for example: 1.1, 1.2, 1.3.

List Style
(style)

no

none

Use this parameter to select the style of bullet point for each list item.  You can use any valid CSS style.  For example:

  • none — no list style is displayed
  • circle ---  the list style is a circle
  • disc — the list style is a filled circle — this is the typical bullet list, and is the one we're using for this example list
  • square — the list style is a square
  • decimal — the list is numbered (1, 2, 3, 4, 5)
  • lower-alpha — the list is lower-case, alphabetised (a, b, c, d, e)
  • lower-roman — the list style is lower roman numerals (i, ii, iii, iv, v, vi)
  • upper-roman — the list style is upper roman numerals (I, II, III, IV, V, VI)

Separator
(separator)

no

brackets

This parameter applies to "flat" lists only.  Use this parameter to style the display of a "flat" or horizontal list.  You can enter any of the following parameters:

  • brackets — Each item is enclosed by square brackets: [ ].
  • braces — Each item is enclosed by braces: { }.
  • parens — Each item is enclosed by parentheses: ( ).
  • pipe — Each item is separated by a pipe:
  • anything — Each is separated by the value you enter. You can enter any text as a separator, for example "***". If using a custom separator, be aware that text displays exactly as entered, with no additional white space to further separate the characters.

Indent

no

 

Use this parameter to style the indent for a "list" according to CSS quantities, entering "10px" will successively indent list heading groups 10px. For example, h1 headings will be indented 10px and h2 headings will be indented an additional 10px.

Minimum Heading Level
(minLevel)

no

1

Use this parameter to select the heading level to start your TOC  list.  For example, 2 will list h2, h3, and h4 headings, but will not include h1 headings.

Maximum Heading Level
(maxLevel)

no

7

Use this parameter to select the maximum heading levels to include.  For example, 2 will list h1 and h2, but will not include h3 and below.

Include Headings
(include)

no

 

Use this parameter as a way of filtering to include headings according to specific criteria. You can use wildcard characters to filter the headings. See Sun's Regex documentation for examples of constructing regular expression strings.

Because '|' is the macro parameter separator, use a comma ',' where you would normally use a '|'. If you need to match a comma, use its escape code: 'x2c'.


Exclude Headings
(exclude)

no

 

Use this parameter as a way of filtering to enclude headings according to specific criteria. You can use wildcard characters to filter the headings. See Sun's Regex documentation for examples of constructing regular expression strings.

Because '|' is the macro parameter separator, use a comma ',' where you would normally use a '|'. If you need to match a comma, use its escape code: 'x2c'.


Printable
(printable)

no

true

By default, the TOC is set to print. If you set this parameter to false, the TOC will not be visible when you print the page.

CSS Class Name
(class)

no

 

If you have a custom TOC in your CSS style sheet, you can use this parameter to output the TOC with the specified "class" attribute.

Examples

The examples are based on a page with the following headings:

h1. Places
h2. Favourite Places
h2. Unknown Places
h1. Foods
h2. Favourite Foods
h2. Unknown Foods
h1. Things
h2. Favourite Things
h2. Unknown Things

Basic Table of Contents

This will display all level 1 and level 2 headings as numbered lists.

{toc:style=decimal|maxLevel=2}

Screenshot: Basic TOC example

Filtered Table of Contents

This will filter all headings to include those that contain "Favourite", but will exclude any heading which ends with the word "Things'. The list is styled with Roman numerals. It will not display on the printed page.

{toc:style=upper-roman|indent=10px|maxLevel=2|include=Favourite.*|exclude=.*Things|printable=false}

Screenshot: Filtered TOC example

Flat List

This will filter all headings to render a flat list of 'Unknowns' enclosed in square brackets.

{toc:type=flat|maxLevel=2|include=Unknown.*}

Screenshot: TOC displayed as flat list

Notes

  • Due to an outstanding issue in the Table of Contents macro (CONF-10619), the Macro Browser's Refresh function does not render any parameter modifications. Currently, the rendering of parameter value modifications to the Table of Contents macro occurs only after the page is saved.
  • Using HTML Heading Markup with the Table of Contents Macro — The Table of Contents macro cannot handle HTML heading markup on its own. Hence, if you used the HTML and HTML Include macros to render HTML heading markup in a Confluence page, the Table of Contents macro will not create a contents list out of these headings. (For more information on about this issue, please refer to TOC-93.)
    However, if you insert an HTML anchor into each HTML heading on your page (based on the following syntax), the Table of Contents macro will incorporate these headings into your contents list.
    <h2><a name="pagename-headingname"></a>Heading Name</h2>
    The syntax for the anchor name is usually the page name and heading name separated by a hyphen, in which the page and heading names have all spaces removed and are converted to lowercase. If punctuation marks occur within a page or heading name, each mark should usually be converted to its URL escape code in the anchor name.
RELATED TOPICS

Table of Contents Zone Macro
Pagetree Macro
Adding a Navigation Sidebar
Working with Macros

Take me back to the Wikis Help Guide.