Create a Table of Contents in Confluence that spans child pages AND displays H2 and H3 titles
Asked by Don Wallbaum:

Is it possible to have a table of content (or other similar system) that displays the H1, H2, Hx titles for the root page and children pages? I would like to have something like this:

HOME PAGE

\* Introduction

\*FAQ

\* Contact Us

CHILD PAGE 2

\* How to Find Us

\* Requesting Support

\* Holiday Hours

CHILD PAGE 3

\*About our Staff

-- Administration

-- IT

-- Billing and Inquiries

The CHILDREN MACRO and PAGE TREE MACRO display the pages:

* Home Page
* Child Page 2
* Child Page 3

And the TOC displays the subheads of the current page:

HOME PAGE

* Introduction
* FAQ
* Contact Us

But I don't see anything that combines the ability to drill down to the subheads as the TOC can on the children pages.

Any suggestions? I am not looking for a complex, custom macro (out of my skillset) but was wondering if there were a solution I had overlooked.

Thx!!


Answers:
author: Pat D'Ambrosio
body: I developed this solution:

1. Create a blank page entitled: TABLE OF CONTENTS.

2. Space Settings \> Reorder pages: Make all of your parent pages child pages of TABLE OF CONTENTS.

3. I have sections: In each section page (and otherwise these are blank), I inserted the Children Display Macro. Show Descendants: Click. Heading Style: H2/3--see example below. (I made no other changes.)

4. TABLE OF CONTENTS page: I inserted the Children Display Macro. Show Descendants: Click. Heading Style: H1. (I made no other changes.)

What appears on my TABLE OF CONTENTS page:

**SECTION A: Used H2**

**SECTION B: Used H2**

**SUBSECTION a: Used H3**

Page 1

Page 2

**SUBSECTION b: Used H3**

Page 1

Page2

and so on.

Hint: You can copy and paste these macros.

IMHO: Why isn't there a Space ToC macro? This is a rudimentary req for all Documentation??

comments: author: Pat D'Ambrosio
body: Note: I just ran this op on another space and did not use the Children Display macro and I still see what I see above.

Best Practice Hint: Go the extra step and copy-paste your h2/h3 children macros into your subsections and their child subsections. Your users with thank you!


author: Lloyd Blythen
body: Great idea Don. Very similar requirement here which also would be solved by a solution to your issue. In our index page we can use a child-pages macro but it'll only list child pages. If headings on any of them are of interest to people consulting the index -- which high-level headings invariably are -- then they're invisible because the child-pages macro doesn't display them. A composite which could list child pages and their headings down to a selected level would be very useful.


author: Don Wallbaum
body: Hi Bill,

You mean why do I want to do this? Fair enough inquiry and I admit this may not be a common situation.

My company wants to organize the content of various team within a common Confluence look and feel, if you will. Each team uses Confluence but in its own way, but generally populating Confluence with the same type of information.

The idea I am playing with is to have "one page to rule them all and in the darkness bind them" meaning I would like to have one page that is essentially an index page to all the subordinate content.

So you may have one doc that has a team calendar, another with Retrospective or meeting notes, and so forth.

For example then, I would have a page "Staff". On the page "Staff" I would have an H2 (or whatever) for "Director" and below that the director contact info. Another would be "Technical Support" and below that the tech support contact person. A third might be "Writer" and below that would be the contact info for the team writer.

Or if there is a longer, say requirements doc, then I would have a "Requirements" page that would contain headings for say, "Summary", "Business Impact", "Budget Analysis", "Time and Manpower Estimates" and so forth.

Now, back to the "one page to rule them all..."

The index or TOC or Child Pages list or whatever would now display in one place all the team's content:

Calendar

\*January

\* Februrary

\* March.....

Retrospective

\*Sprint

\* Starfish

Meeting notes (stand-alone series of pages)

Staff

. \* Director

\* Technical Support

\* Writer

Requirements

\*Summary

\* Business Impact

\* Budget Analysis

\* Time and Manpower Estimates

NOW, some of this can be accomplished by just having a TOC that reports out child page names. And this approach is not totally fleshed out yet.

BUT, since there is a macro for child pages, and a macro for a heading-based TOC, it seems to me (with no knowledge whatsoever) that one could have the two outputs combined to have a TOC reporting child pages that have a sub-entries, the heading level content.

The advantage for ME (since it is all about ME) is that content won't get lost. The "index" page will now dynamically update as new content is added, and there will be a fair degree of discrimination with what that content on the page actually is, since the H2, H3 or whatever topic heads are selected, also are reported back and displayed. If people want to find something, they can hit the "index" page, scan a rather comprehensive TOC-style list, then click directly to the desired content.

Thx!

Don Wallbaum


author: Arseny Poltorak
body: Here's the simplest 2-step way to add a table of contents that includes both children pages and relevant headings inside those pages. So, for example, if you have your space in the following format:

Main Page

* Subpage 1
* Subpage 2

And each of the subpages has sections - a structure of headings that you want to show:

* Subpage 1
  * Section 1
    * Subsection 1
    * Subsection 2
  * Section 2
  * Section 3
* Subpage 2
  * Section 1
  * Section 2

Here's how you do it:

1. Add a Children Display macro to the parent page (Main Page in the above example) with an Excerpt Display setting set to "rich text". It's a setting inside Chidren Display macro that shows "none" by default. Change it to "rich text".
2. Then add Excerpt macro to each of the children pages (Subpages in the above example), and put Table of Contents macro (TOC) inside. That's it.

Adding a macro is as easy as typing "/" followed by keywords, like "children" or "table".

After adding TOC inside the Excerpt, you can also add a paragraph (just hit "Enter" key right after you've added TOC). That way your Children Display on the parent page will look a bit neater.

![Module1.png](https://community.atlassian.com/t5/image/serverpage/image-id/146262iC0DAC182B9DF6671/image-dimensions/319x197?v=v2 "Module1.png")

You can configure the max/min heading level you want to display in TOC. So, like, if you don't want to show any headings for a particular subpage, no problemo, just configure the TOC to what you need to have displayed. Also, you can add "Table of Contents:" before the Excerpt macro to have a neater visual look of each subpage, if you want.

And if you'd rather not have TOC on the children pages, just configure Excerpt macro to "Hide Excerpted Content". Then your subpages will be clean from TOC, but the Main Page will still show it.

Anyways, two easy steps above will get you a good table of content in the parent page that stretches across all children pages and headings inside those pages.


author: Erik Anderson
body: Yet another Confluence user in search of this kind of solution.

Sometimes, a flat list of pages is not enough. We would very much like to be able to also show the main headings in each child page.

The workaround is far from elegant --

* Do major surgery on each child page with headings, to cut-and-paste each heading section into sub-pages. ? This is enormously tedious and a pain for future content maintenance.

For large spaces with legacy content, this workaround is untenable. For new content, this workaround is also usually untenable, due to the high maintenance overhead.


author: Arlen Johnson
body: I am also looking for a solution to this - exactly as the OP suggests: I want to see the child pages listed in a TOC with all headings listed underneath them. This would produce a complete TOC for an entire section of documentation.


author: Adnan Siddiqui
body: Did anyone find a solution to this problem?


author: Manohar Dondlapally
body: I have the same requirement as I am generating the PDF document, It's needed to display the contents of H1, H1, H3 styles in the TOC as subsections.


author: Bill Bailey
body: My instinct is to just assign each team a space, then set the left-hand navigation to Page tree display. Lastly, on the space home page, insert a search box macro, restricted to that space.

You wont have a display showing headings on the page, but you will have a restricted page tree and search box. With search, nothing will get lost.


author: Don Wallbaum
body: Bill, I ended up replying to my original post - error on my part. Please scroll up to see my response to your question.

Thx.

Don


author: Bill Bailey
body: I am curious about the use model.