Confluence macro in Forge UI kit - best way to calculate URLs to other items

I’m converting some on-prem user macros to Forge UI kit and am having trouble calculating the correct URLs to child pages and labels.

I could hack my way into a child page URL using this ugliness

<Link appearance="link" href={`../../pages/${}`}>{entry.title}</Link>

but the format for a label seems to require “/labels” before the space ID, (/wiki/label/~xxxxx/label1 ) so my double dots don’t cut it.

<Link appearance="link" href={`../../${labelName}`}>{labelName}</Link>

Is there an API helper for this?

Full example:

  const renderTableRows = (results) => {
    return( => (
          <Text><Link appearance="link" href={`../../pages/${}`}>{entry.title}</Link></Text>
            { pageLabelMap.get( => (
              <Link appearance="link" href={`../../${labelName}`}>{labelName}</Link>

Welcome to the Atlassian Developer Community, @HughKelley.

Assuming you have the necessary information like page ID and label name from results and pageLabelMap, can you use a path starting from /wiki instead of ../../?

For example, I tried this approach and the links worked similarly to how I understood your code snippet should; I did not see you referencing the product context so I added it here so that you can derive the spaceKey of the current space your page is in.

    const context = useProductContext();
    <Link appearance="link" href={`/wiki/spaces/${context.spaceKey}/pages/${}`}>{entry.title}</Link>

    <Link appearance="link" href={`/wiki/label/${context.spaceKey}/${labelName}`}>{labelName}</Link>

Let us know if this works for your use case.


That solution works for relative paths. The relative paths seems fine in my dev environment but when I promoted to production, that Confluence site won’t “honor” those HREFs. See Forge <Link> elements not getting href in production environment, fine in development

Is there a way to get the root URL of the space so that I can calculate a full URL? I don’t see that data in product context.

Hi @HughKelley,

I tried replicating your issue and deployed the same app in production but it works as expected i.e., relative paths are supported as documented

The prop href behaves like an HTML href. You should include http(s):// for full URLs. Relative paths, such as /wiki, are also supported.

If the relative path does not continue to work on your end, kindly raise a bug report in the Developer Support Portal so that it can be investigated further.

The base URL can be retrieved via the Get system info REST API (but this will result in an additional API call).


Thanks. I opened ECOHELP-27563 regarding the about:blank.

I tried adding the getSystemInfo REST call but the required permissions seem excessive just to learn the base URL. I added the read perm to the manifest but still get a 401. Adding the manage perm is a non-starter.

Classic RECOMMENDED: manage:confluence-configuration
Granular: read:configuration:confluence