The Table of Contents macro scans the headings on the current Confluence page to create a table of contents based on those headings. This helps readers find their way around lengthy pages, by summarizing the content structure and providing links to headings.
Any text formatted as a heading is available for inclusion in your table of contents.
Want to see the Table of Contents macro in action? Check out how it's used in Creating insightful customer interview pages.
Using the Table of Contents macro
Hint: For quick access from the editor toolbar, choose Insert > Table of Contents.
To add the Table of Contents macro to a page:
- In the Confluence editor, choose > Other Macros
- Find and select the required macro
Speeding up macro entry with autocomplete:
- In the new editor - Type / and the beginning of an element (tool or things in the insert menu) to see a list of suggestions.
- In the legacy editor - Type { and the beginning of the macro name to see a list of suggested macros.
Details are in Keyboard shortcuts, markdown, and autocomplete.
To edit an existing macro
Click the macro placeholder and choose Edit. A macro dialog window will open, where you can edit the parameters of the macro.
Macro parameters
Parameters are options that you can set to control the content or format of the macro output. Where the parameter name used in Confluence storage format or wikimarkup is different to the label used in the macro browser, it will be listed below in brackets (example
).
Parameter | Default | Description |
---|---|---|
Output Type | list |
|
Display Section Numbering | clear | Select the check box to apply outline numbering to your headings, for example: 1.1, 1.2, 1.3. |
List Style | disc | Select the style of bullet point for each list item. You can use any valid CSS style. For example:
|
Heading Indent | Sets the indent for a list according to CSS quantities. Entering | |
Separator | brackets | This parameter applies to flat lists only. You can enter any of the following values:
|
Minimum Heading Level | 1 | Select the highest heading level to start your TOC list. For example, entering 2 will include levels 2, and lower, headings, but will not include level 1 headings. |
Maximum Heading Level | 7 | Select the lowest heading level to include. For example, entering 2 will include levels 1 and 2, but will not include level 3 headings and below. |
Include Headings | Filter headings to include according to specific criteria. You can use wildcard characters. If you only want the Overview and Summary headings to appear, enter | |
Exclude Headings | Filter headings to exclude according to specific criteria. You can use wildcard characters. If the headings you want to exclude are Overview and Summary, enter | |
Printable | checked | By default, the TOC is set to print. If you clear the check box, the TOC will not be visible when you print the page. |
CSS Class Name | If you have custom TOC styles in your CSS style sheet, use this parameter to output the TOC inside | |
Absolute URL (absoluteURL ) | By default, the links in the TOC are relative URLs pointing to the current page. If checked, the links in the TOC will be full URLs. This setting is useful when you are including a page with a Table of Contents in another page, and want to control where the links should take the user. |
Examples
The examples below are based on this table of contents:
Filtered Table of Contents
This example filters the headings to include those that contain 'Favorite', but excludes headings which end with 'Things'. The list is styled with Roman numerals.
Parameter | Value |
---|---|
List Style | upper-roman |
Include Headings | Favourite.* |
Exclude Headings | .*Things |
The resulting table of contents is:
Flat List
This example filters all headings to render a flat list of 'Unknowns' enclosed in square brackets (the default list style).
Parameter | Value |
---|---|
Output Type | flat |
Maximum Heading Level | 2 |
Include Headings | Unknown.* |
The resulting table of contents is:
Wiki markup example
Wiki markup is only supported in the legacy editor.
Wiki markup is useful when you need to add a macro outside the editor, for example as custom content in the sidebar, header or footer of a space.
Macro name: toc
Macro body: None.
This example shows a list-type table of contents.
{toc:printable=true|style=square|maxLevel=2|indent=5px|minLevel=2|class=bigpink|exclude=[1//2]|type=list|outline=true|include=.*}
This example shows a flat table of contents.
{toc:printable=true|maxLevel=2|minLevel=2|class=bigpink|exclude=[1//2]|type=flat|outline=true|separator=pipe|include=.*}
Notes
- When you use a Table of Contents macro in a template, you will see an error when you preview the template itself. But the Table of Contents macro works on the pages that people create from the template – the table of contents shows up after they have saved the page. (This is probably because the template is not defined as a page, and the Table of Contents macro works for pages only.)
- The Table of Contents macro only displays page or blog post content. You can't use it to add a table of contents of headings in a comment for example.
- 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.