TOC links don't work when using INCLUDE macro to display page?

Manny Ju August 16, 2011

We're using Confluence 3.0.1.

I want to display an entire page within another page - so I'm using the INCLUDE macro to do this.

The page that I want displayed has a TOC macro.

Problem: Even through the Table of Contents is correctly displayed on my main page, the hyperlinks don't work.

Any suggestions?

8 answers

1 vote
Communications Staff
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 27, 2013

This is really a hassle. It would be nice to have a setting -- "url=local|absolute". Please.

1 vote
Joerg Bencke
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 28, 2012

I cant explain it, but have you tried using the import macro from the adaptavist theme builder plugin ? Just be aware it might create additional sideeffects since the evaluation-context of the wikimarkup changes. (See image from : http://jodiem.com.au/2011/08/13/the-one-thing-in-one-place-once-rule-using-confluence/ )

Differences in inclusion options

1 vote
Jennifer S
Contributor
September 28, 2011

This may not be the case in this instance - but we had troubles with this and realized the include pages had Wiki Markup inside a heading. For example:

h1.{color:#000000}{*}This is the Heading{*}{color}

We found out the mark up within the heading was disabling the table of contents and the reason our Include macros were not generating a table of contents with working hyperlinks.

This may not be the answer in your case but I thought I'd throw it out there. :)

Manny Ju October 14, 2011

swanj115 - thanks for the idea. Unfortunately the page doesn't have any markups similar to the ones you mentioned.

0 votes
Steffen Heller
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2012

Hello,

what the toc macro does is read the headlines from a page and create toc entries with anchor hyperlinks to these headlines.
As a result the hyperlinks of a toc entry on a PageA look like this:

.../display/~Username/PageA#PageA-Anchorname

=> These hyperlinks will work!

But: If PageA is included in PageB the hyperlinks of the toc entries in -now- PageB will look a little different:

.../display/~Username/PageB#PageA-Anchorname

=> These hyperlinks will not work!

I think there is no way to "repair" this directly.
As a workaround one could use the toc macro and adapt the hyperlinks afterwards:

  • Include the toc macro on the wiki page
  • Quit Edit mode and copy the resulting toc from the html page into the clipboard
  • Go back to Edit mode and enter the data from the clipboard into Rich Text view
  • Switch to Markup view, look for the wiki code of the toc and adapt the hyperlinks manually:
    • What you find is something like this:
      * [Anchorname|display/~Username/PageName#PageName-Anchorname]
    • Change it to this:
      * [Anchorname|#Anchorname]

I actually do this a lot ;-)

0 votes
Deleted user July 10, 2012

Manny, I've found a workaround. It's not a very good one, but it does work.

I've been adding a manual high-level table of contents, using headings like this on the original page.

| [#First heading] | [#Second heading] |

h2. First heading

Some text

h2. Second heading 

More text

That renders like this

When you include the original page somewhere else, the manual links will work. 

What I don't understand is why that kind of relative link DOES work, but the one inside the toc macro doesn't.
Crumbs, I hate wysiwyg editors. You can't see where the code block starts and ends. This ISN'T part of the code block. Grr. And there SHOULD NOT be <br> character in the first example.

Deleted user July 10, 2012

OK, I've calmed down after my wysiwyg editing experience. I also want to add some 'gotchas' you need to look out for if you create a manual toc like that. My instructions assume you're using wiki markup, not rich text.

  • Using the #Heading text local link syntax is fussy. You need to get spelling and capital letters exactly right or the link will silently fail
  • If anyone changes the words in the heading text, you also have to re-edit the link or it will break
  • It's more work, but is more reliable, to use an anchor instead of the #Heading text syntax ... so, just above the h2. (or other heading) in the text, enter {anchor:anchortext1}, then your toc link will look like this: [First heading|#anchortext1] ... by doing that, the heading text in the body of the doc can change (it won't be automatically updated) but at least your link at the top will not break.

So the code would look like this (it will still render exactly the same as the example in my first post)

===============================================

| [First heading#anchortext1] | [Second heading|#anchortext2] |

{anchor:anchortext1}
h2. First heading

Some text


{anchor:anchortext2}
h2. Second heading

More text

===============================================

Edit: Obviously, this is a p.i.t.a. that shouldn't be necessary if the {include} macro didn't break things. Like I said, it's not a GOOD solution, but it does work.

0 votes
Manny Ju April 26, 2012

Unfortunately never got an answer nor found a solution :(

0 votes
Deleted user April 26, 2012

Wondering if you'd found an answer to this? I've got the same problem. It looks as if the toc is displaying relative links, and of course the link doesn't exist on the current page.

0 votes
Betsy Walker
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 18, 2011

Have you tried relocating the Toc macro to the page that uses the Include macro?

Manny Ju August 18, 2011

Tried that. Still no joy. :-(

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events