Skip to end of metadata
Go to start of metadata

Learn how to use the table-of-contents (TOC) macro to create a list of the topics (or sections) of a given wiki page.

The markup language you are using in your Wiki will determine what style of TOC you can create.  The following table shows the markup syntax for each available language.

LanguageDescription and Markup
Creole

Allows you to create a TOC for the Wiki itself or just a page. Use the following to create a page-level TOC

<<toc>> 

You can also create a table of contents for a Wiki use:

<<toc path depth>>

For example, to list all the pages in your Wiki and their headings to a level of 2, enter the following:

<<toc / 2>>

See Macro Reference for Creole Markup in this documentation for more information.

Markdown

You can only create a page-level table of contents. The syntax is:

[TOC]

See the extension documentation for more information.

resStructuredText

You can create a page-level TOC. The syntax is as follows:

.. contents::

See the reStructureText documentation for more information.

TextileYou cannot create a TOC for a page or the Wiki itself with Textile.

 

RELATED TOPICS

Special support for Creole

15 Comments

  1. Anonymous

    It's worth noting that the toc macro isn't expanded when using the preview feature. To see the actual ToC you need to save the wiki page.

  2. Anonymous

    The example should be <<toc / 3>>

  3. Anonymous

    The lack of addressing this ToC issues in a timely manner (repeatedly) has inspired this (once paying) customer to delete all of my personal repositories from Bitbucket and to go with a competitor.  We currently have a broad spectrum of Atlasssian products, to include our 25+ user licenses for Jira, Bamboo, Crucible, and Greenhopper - it's clear that Bitbucket is the bastard-stepchild of the Atlasssian product line. I suggest that anyone else that expects reasonable functionality from Bitbucket's web site and/or the wiki pages (and their support staff) should do the same.  

    https://bitbucket.org/site/master/issue/3097/wiki-toc-macro-error

    https://bitbucket.org/site/master/issue/2989/toc-macro-is-not-working-properly-bb-2475

    https://bitbucket.org/marijnvanderzee/build-wiki/issue/2/a-directory-cannot-have-the-same-name-as

     

     

  4. There are currently some issues with the TOC on a sub-directory page where the links are not generated correctly. I have reported issue #3912.
    --ap 

  5. Was nice if it was possible to sort by name. That's a really good feature.

    1. Good idea.  Check the markup language you are using, it might offer this already.

      1. I'm using creole. And I think is not provided. Is only path and depth. Link: "Syntax<<toc path depth>>"

        1. Apologies.  I should never answer page questions from a conference. You are correct, our TOC macro does not support sort. You can file an enhancement request for this.

  6. Is there a way to include the page title in a wiki (not page) toc? It seems only the Hx tags are evaluated, but the page titles are missing.

    1. What you can do in a page depends on the markup language you use in your Wiki.  Of course, regardless of the language, you can always manually enter the title in the page.  

      1. Anonymous

        I'm using Creole. Now, to autogenerate a TOC for the wiki on the homepage I can use the macro, e.g. like this: <<toc / 3>>. But that will give me the H1-H3 headers. I would like to see the page itself (as specified by its title) in the list.

  7. Anonymous

    And if you click History button,  it seems that it only shows the history of Home.md. Any other changes pushed to the wiki repo (ie. adding of new files) are not shown. Why?

  8. I am exporting a pdf, out from multiple confluence wiki pages. My requirement is to have a minitioc(for h1, h2, h3 etc.) at the top for each page in the exported pdf. Is this possible to generate, and how?

    I don't want to update my wiki pages.

    Thanks.

    1. Good day,

      Thanks for taking the time to comment. I'm wondering if you are looking for confluence help? This topic is specific to Wiki pages created and maintained in Bitbucket. I think this page might help you Exporting Confluence Pages and Spaces to PDF.

      If you are referring to Bitbucket wiki's, you can't do what your seeking from the Bitbucket UI itself. I'm not sure if there is a way to do so with Markdown after you clone the wiki locally.

      Have a great day.