Export pages/space to HTML - inter page links are created in two different ways
Asked by maker:

I have effectively the same question as James Hurrell did regarding how Confluence is crafting links in exported HTML that are to pages that should be internal to a space.

As James described:
> For the majority of the exported pages, when one page references another, the link is created correctly as follows:
>
> \<a href="test%2page.html"\>test page2\</a\> - this then renders as test+page.html in the browser and will call the local copy of the required page. This is fine.
>
> However, sometimes, the link is created as follows with the fully qualified domain name:
>
> \<a href="[https://confluence.domain.com/display/SPACE-NAME/test+page2"\>test]() page2\</a\>
>
> Obviously this breaks the links in our published doc system as the link points to the public address for the Confluence system

In a follow-up post, James seemed to find he wasn't actually exporting his complete space. However, I am seeing this behavior on intra-linked pages within the space even when I use the Normal Export choice on the Export HTML Options page.

It would be great if the exported pages were properly linked, was this feature broken / is there a workaround apart from fixing the links myself using a script?


Answers:
author: Shannon S
body: Hi [@maker](/t5/user/viewprofilepage/user-id/3727478),

Happy to look into this with you. I believe you're referring to this thread, that shares the same title as yours. Is that right?

* [Export pages/space to HTML - inter page links are created in two different ways](https://community.atlassian.com/t5/Confluence-questions/Export-pages-space-to-HTML-inter-page-links-are-created-in-two/qaq-p/359731)

From my understanding, the issue is that when you export a space to HTML, some internal links are linking using the absolute URL whereas others are just using the relative URL, as they should be. Do I have that correctly?

With James' case, this was with Confluence Server version 4.2.12, but I understand that you're on Cloud. Can you confirm that?

With the links that are showing as absolute, are they linking to pages in another space entirely, or within the same space? Can you find any kind of similarity amongst them, or perhaps were they inserted differently into the page?

Looking forward to hearing back from you.

Regards,

Shannon

comments: author: maker
body: Hey Shannon,

Yes this is on the current version of the cloud.   

I'm not sure you have it exactly. Some are linking to the exported html files. Some are linking to a url that requires internet---the actual page's living url.

Effectively all of the interlinking links created using the normal internal page link creation dropdown (with auto suggest completion) link to atlassian.com instead of the local file.

Only the breadcrumbs and auto generated table of contents on the index page link correctly.

It should be shown if you make a few pages and link them by hand then export. But you are also welcome to export my newest created private space to see for yourself.

i worked around this by including in my python script something that matches up the page keys between local file names and remote and replaces the remote urls with the local file names in each link on each page.   

That's a hack around what appears to be a bug though.


author: Shannon S
body: Hi there,

Thank you for the reply. I do know that in the past I saw if anyone manually created a link then it was doing weird thinks with the links, but that was on Server a while ago. I don't think I ever saw that behavior in Cloud.

To fix the problem, you would have to manually update the links by hand, or a script, like you did.

I'll want to test this a bit more next week. Just to be sure - if you were to link by hand in the **New Editor** vs the **Legacy Editor**, do they both replicate the problem? Or only one of the editors?

Shannon


author: maker
body: Shannon,

I compared the editor presented with the images in [this blog entry](https://confluence.atlassian.com/confcloud/confluence-cloud-editor-roadmap-967314556.html) and I'm using the new editor.

I'm not sure about legacy. You'll have to test.


author: Shannon S
body: Good afternoon,

I'm testing this on my Confluence Cloud site, but I have not been able to replicate it.

Here are the steps I took:

1. I created 2 new pages, which I will be linking to.
2. I then created a 3rd page, on which I will be linking these pages.
3. I first linked the 2 pages while using the insert link dialogue: ![CleanShot 2020-02-10 at 14.20.08.png](https://community.atlassian.com/t5/image/serverpage/image-id/82550i534FE14FE9A5AE28/image-size/large?v=v2&px=999 "CleanShot 2020-02-10 at 14.20.08.png")
4. I then linked the 2 pages while manually pasting the full link to the pages.
5. In both cases, the links displayed properly:  
   ![CleanShot 2020-02-10 at 14.10.03.png](https://community.atlassian.com/t5/image/serverpage/image-id/82551iB305C0908CAE693A/image-dimensions/203x204?v=v2 "CleanShot 2020-02-10 at 14.10.03.png")
6. When I export the space to HTML, the links are formed as local links and do not point back to the Cloud site.

Can you tell me if this is how you are replicating the issue on your end?

You mentioned earlier that I can export your newest created private space to test, but unfortunately I am not able to gain access to your account via Community. If you've raised a support ticket [through our Support Portal](https://support.atlassian.com/contact), then we can have a look at your site.

I want to make sure that we can't replicate the problem externally first, and if not, I can help you to raise a case for this and we can have a look at your site.

Regards,

Shannon


author: maker
body: Hey Shannon,

I created a ticket, JST-549585, to allow access to the site.

<br />

This happens between the second level and third level pages in the hierarchy.

You have to create a page (page a), then a child page (page a-1) of that.

Then go to the breadcrumb for page a and edit that page to have a link to its child using the automated linking.

Links from that page to its children are broken. (they link externally)

The space overview links created by the export are correct. Its important to note not all links are incorrect.

**Comma Encoding in Space Name Bug**

I also found another bug where if you have a space name with a comma in it, the comma is incorrectly encoded in the filename. It should be %2C, but it appears to create files that have the percent sign encoded twice.

To repro this:

- Create a page with a comma in the title

- Export the html

- Click the main navigation link auto generated to the page

- Link is broken.


author: Shannon S
body: Hello,

Thank you for reporting the issue in a support ticket. I've included an internal summary as well of what I have tested so far. I'll be watching the case so we can update this thread with the results.

As for the 2nd bug you found, I believe it could be related to this bug:

* [CONFCLOUD-62585](https://jira.atlassian.com/browse/CONFCLOUD-62585) *Links break on HTML export file if the page title has a special character*

It's been closed as a timeout, I think because it's a few years old and we only had one vote of any customers saying they were having the same issue. I'm in touch now with the developer, because I want to know if there's anything we can do to help with this since you've discovered this bug too.

Could you do me a favor, and raise a new question on Community about this bug, and mention my name? That way, I can follow-up with you separately on that when I hear back from the developer and we have a thread dedicated to it in case others are having the same issue. The newer the thread, the more likely others will see it and say if they're having the same problem.

Thanks again!

Shannon


author: maker
body: Hey Shannon,

You bet. Thanks for keeping an eye on it. I do have a workaround for the linking written in a script but I need to fix it to now work with page anchors. It would be cool if links worked out of the box.

That does look like the bug I'm seeing with commas.

I am guessing html export must not be a very commonly used feature.

The comma workaround is to just not use punctuation, although this is probably a one line fix too. Regardless, I created [a question on it](https://community.atlassian.com/t5/Confluence-questions/Do-Pages-with-Punctuation-in-their-Title-have-Broken-Links-when/qaq-p/1298614#M167707) with an @ for you.

Thank you again for your help.


author: Shannon S
body: Hi there,

Thanks again for creating that new thread; I followed up with you there.

I see on your ticket in support, the engineer created a new request for your other issue, in order to improve the handling of links in the new editor.

* [CONFCLOUD-69336](https://jira.atlassian.com/browse/CONFCLOUD-69336) *Improve how Confluence works with links in the new editing experience*

Can you let me know if you have any follow-up questions about that?

Shannon


author: maker
body: Hey Shannon, thank you for your support on both of these tickets. I appreciate the response between both you and the confluence engineer that wrote me. I consider this question resolved and very much appreciate all of your help.


author: Shannon S
body: I'm happy to hear that! Glad we could help.

Take care, and have a pleasant rest of your week.

Shannon


Tags: cloud

confluence-cloud