The Table of Contents Zone macro enables you to mark out a 'page zone' from which you can use the headings to create a table of contents. Styling the headings as a flat list enables you to enclose the page text by top and bottom navigation bars similar to web navigation. When styled as a list, headings are indented progressively.
On this page:
Usage with the Macro Browser
To insert the Pagetree macro into a page using the Macro Browser,
- Open the Confluence page or blog post that you want to edit, then click the 'Edit' button.
- Click the Macro Browser icon on the toolbar. The macro browser window will open.
- 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.
- Click the desired macro.
- Set the macro parameters to your requirements. If desired, you can preview these changes by clicking 'Refresh'.
- Click 'Insert' to add the macro onto the page.
You can also insert macros via autocomplete. For more information, see Using Autocomplete in the Rich Text Editor.
Once you've found the Pagetree 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-zone:type:=[list,flat]|maxLevel=1} Content in the zone, including other macros and page content. {toc-zone}
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 |
---|---|---|---|
Location | no | both | Use this parameter to specify whether the output list displays at the top, at the bottom, or encloses the page zone content. By default, the macro displays headings at both the top and the bottom of the page. |
Output 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 | no | false | Select the tick box to apply outline numbering to your headings, for example: 1.1, 1.2, 1.3. |
List 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:
|
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:
|
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 | 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 | 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 | 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: |
Exclude Headings | 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: |
Printable | no | true | By default, the TOC is set to print. If you set this parameter to |
CSS Class Name | 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 only level 1 headings as a numbered list at the top of the page.
{toc-zone:type|location=top|type=flat|maxLevel=1} h1. Places h2. Favourite Places h2. Unknown Places h1. Foods h2. Favourite Foods h2. Unknown Foods h1. Things h2. Favourite Things h2. Unknown Things {toc-zone}
Filtered Table of Contents
This example 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-zone:minLevel=2|maxLevel=4|exclude=Adding your own Tip} Page zone content {toc-zone}
You can see this example 'live by visiting the Tips via Twitter page.
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: Filtered TOC 'zone' headings displayed as flat list
Notes
- Due to an outstanding issue in the Table of Contents Zone 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 Zone macro occurs only after the page is saved.
Using HTML Heading Markup with the Table of Contents Zone Macro — The Table of Contents Zone 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 Zone 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 Zone 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 Macro
Pagetree Macro
Adding a Navigation Sidebar
Working with Macros
Take me back to the Wikis Help Guide.