local links in HTML macro

sjaak derksen December 7, 2024

Hi,

I want to publish generated W3C respec HTML in a confluence page via the HTML macro.

I solved the separate CSS by including it in the HTML. However, the respec also contains: <section id="95f0458e-6677-46c7-b93a-c3707cf49b2c">

 

and references to a section like this : <a href=#95f0458e-6677-46c7-b93a-c3707cf49b2c>Identification of Borehole</a>

 

Clicking links refers to URL's outside the page. How can I fix this?

1 answer

0 votes
Humashankar VJ
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.
December 8, 2024

Hi @sjaak derksen 

Ensure that the links are relative to the Confluence page rather than absolute URLs.

  • When including HTML content with internal links, using relative links or anchors specific to the Confluence page is crucial.
  • Instead of using <a href="#95f0458e-6677-46c7-b93a-c3707cf49b2c">Identification of Borehole</a>, ensure that the id and href attributes are correctly referenced within the same HTML document
  • This may involve adjusting your HTML by correctly referencing the id and href attributes within the same document.

If the HTML is generated and IDs cannot be changed, manual adjustments may be necessary to ensure consistency and relative linking.

Hope this helps - Happy to help further!!
Thank you very much and have a great one!
Warm regards

 

sjaak derksen December 8, 2024

Hi,

First of all, thanks :) . I have the ability to change the href and section to whatever is required. The problem I'm facing is: what would that be? The links are taken relative to the space. 

So even if I make the href completely absolute, I guess I need to include the macro (id) itself somehow in the url, right?

 

Best regards,

Sjaak

Like Humashankar VJ likes this
Humashankar VJ
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.
December 8, 2024

Hi @sjaak derksen 

You don't need to include the macro ID in the URL. Use the #pagetitle_anchorname format for relative links or the full URL with the anchor (e.g., https://your-confluence-instance.com/display/SPACEKEY/PAGE#anchorname) for absolute links.

This should resolve the issue of links being relative to the space

Best Regards

sjaak derksen December 12, 2024

Are you sure this url format works? I read this article and it mentions: "Platform notice: Server and Data Center only."

I used these URL's just to have an absolute path to address the page (not an anchor in the page yet)

url.png

Note: I did not even try to address the anchor itself yet.

url1.png

does work. I do not know how the respec javascript code of w3c is going to handle this to generate the index.

Standard everything seems to be resolved with respect to the base url (so without the "wiki/spaces/..." that means that I've somehow got to include the whole path from there on, knowing space-id and knowing page-id and page-name

Adding an anchor to the url does not jump into the macro. Instead it reloads the macro and ends at the top (not at the anchor)

Note: I can see that the space-id is replaced by the key (I'm using my personal confluence page to test). But directly using that with the `#anchor` extension does not work either.

sjaak derksen December 12, 2024

To further clarify:

When I use the URL "https://.../wiki/spaces/437059610/pages/781222011/Test#blah" I can see a new loading indicator loading the macro (its an attachment) and the browser just jumps to the top of the html document.

I've tried the short URL, the smart link format.. no difference.

 

Like Humashankar VJ likes this
Humashankar VJ
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.
December 12, 2024

Thanks for adding more Information.

Can you also check if the page title contains special characters, use the page ID instead of the page title to avoid that part, as we have to see what is in the stem.

Regards

sjaak derksen December 12, 2024

REST v2 request, getpages.. response body (json): "title":"Test1"

sjaak derksen December 12, 2024

so nothing particular there (as far as I can see)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events