Broken link on page when copying the space

Dominik Gashi October 24, 2023

Hi there, 

I have a space with multiple pages. In the pages I have links to other pages in the same space. I had to copy the whole space. Now all links of the pages in the copied space refers to the pages in the old space. 

I want that the links would refer on the page in the copied space. 

I have thousands of pages with links in that space and to change those manually it would take a lot of time. Is there maybe a workaround? 

Thanks. 

2 answers

2 accepted

2 votes
Answer accepted
Helmy Ibrahim _Adaptavist_
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.
November 2, 2023

Hi @Dominik Gashi

I am with the ScriptRunner Support Team.

Following up on @Andrii Maliuta's comment, we do have an example of a find-and-replace script that you can use with ScriptRunner to bulk update Confluence's page storage format.

Please find it here: https://www.scriptrunnerhq.com/inspiration/blog/find-and-replace-text-across-several-confluence-pages

From what I understand, the links in the target Space refer to the pages in the source Space. If that is the case, you would need to update the parameter value of ri:space-key from the source-space key, to the target-space key.

For reference, here is what the Confluence Link storage looks like:

<ac:link>
<
ri:page
ri:space-key="SPACEKEY"
ri:content-title="PAGE TITLE HERE"
/>
</ac:link>

Let me know if you have any further questions!

Kind Regards,
Helmy

Dominik Gashi November 8, 2023

Hi @Helmy Ibrahim _Adaptavist_ 

Thank you for following up Andrii's comment and for the detailed explanation. I could solve it with the ScriptRunner. 

Like # people like this
0 votes
Answer accepted
Andrii Maliuta
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.
October 25, 2023

Hello @Dominik Gashi ,

Looks like you set those links as WEB links and not as Confluence Smart links

so it is treated as just href HTML text and after you move or copy the page it will remain static.

If you set links to Confluence pages/blogs/attachments as SMART links, it will adjust when renaming/copying/moving as needed.

You can change the links format using scripts or custom apps.addons.   

Dominik Gashi October 31, 2023

Hello @Andrii Maliuta , 

Thank you for your message and for your help! The links we are using are normal links that refer to a page on that space. When copying the whole space in refers still to the old page in the old space not in the copied page in the copied space. 

I think smart links are only available in Cloud. We are on Confluence Server. You mentioned that it's possible to change the links with apps. Do you know by change an app that can do that? 

Thanks. 

Andrii Maliuta
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.
October 31, 2023

@Dominik Gashi 

the 2nd link I mentioned is for Server/Data Center (

)

Please check the Storage Format of the links on pages if it is simple 'a:href' or it is xHTML 'ac:link'. The Confluence wise links are of ac:link type.

Andrii Maliuta
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.
October 31, 2023

>> You mentioned that it's possible to change the links with apps. Do you know by change an app that can do that

Yes, you just need to change the format of the link inside page body.

  • get pages with links
  • get pages bodies
  • replace href format with ac:link format
  • save changes on pages

For this you can use tools ScriptRunner with Java API or any HTP client and REST API.

Dominik Gashi November 8, 2023

Thank you @Andrii Maliuta !
I tested it out and it worked. 

Like Andrii Maliuta likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events