Can we link to a confluence page using the path of that page rather than what appears in the address

david Chevreau
Contributor
August 9, 2021

Hello,

as the subject says, can we link to a confluence page using the path of that page (ie space/page/page/page) rather than what appears in the address bar?

Thanks.

5 answers

1 accepted

1 vote
Answer accepted
david Chevreau
Contributor
August 9, 2021

In fact, i want a full path link to use from an external app with variables to define the link. Because as it is, i should perform the creation of a space for each environnement we use instead of creating subpages as we want to do. (Perhaps it's a solution...)

But if you have another solution with tags or anchors, i take it. 

Nic Brough -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.
August 9, 2021

Ok, well that's nonsense, the url is what you want in the external link, not space and page names.

You could code your application to understand and replicate Confluence page urls given the space and page name though - the urls are created from base url + page-area + space key + page name (assuming you're using a page title that does not have unusual characters in it).  If you code for that, your application will be able to work out the link.

david Chevreau
Contributor
August 9, 2021

that's what i'm doing now. thanks

Nic Brough -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.
August 9, 2021

Ok, great.  

I didn't mention the breadcrumbs before - they're not actually there, there is no structure for them in Confluence pages, each space just contains a pile of uniquely named pages.  Hence, they are not part of the url for a page either.  The page tree is built separately in a pile of functions that effectively builds an index and then shows it to us in various ways in the UI.

That actually makes your code a bit more simple - you don't need to worry about the tree/breadcrumbs/container stuff.  It's just "page X in space Y in Confluence Z"

Like david Chevreau likes this
1 vote
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 9, 2021

Hi @david Chevreau

I'm a bit confused. You want to link a page within confluence using "breadcrumbs", or you want a full link path? And what is it about the space creation?

What exactly you want to achieve?

david Chevreau
Contributor
August 9, 2021

i'd love to make an url with the tree structure to adress confluence page from another app which uses this same structure.

But it is simpler like it exists in case of space change. I will do with space name and page name.

Thanks for your concern.

Like Piotr Apczyński likes this
david Chevreau
Contributor
August 9, 2021

PS: i'm a relatively newbie in using confluence and a simple user, not admin (it limits possibilities). So i'm not very used to confluence "thinking".

0 votes
Matthew Beda
Contributor
February 26, 2025

Expanding on previous Macro made by @mykhailo m 

BreadCrumb UserMacro - For use on Confluence DC

 

## Macro Name: breadcrumbles

## Macro Title: BreadCrumbles

## Description: Creates Breadcrumb for current page

## Category: Administration

## Macro Body Processing: No Macro Body

##Template: ----begin code

## @noparams

#set($breadcrumbsAsHtml ='')

#set($currentPageID = $content.id)

#getBreadcrumbs($content.id)

<div class='BreadCrumbles'>$breadcrumbsAsHtml</div>

##recursive macro to get the path to page breadcrumbs

#macro( getBreadcrumbs $contentID )

    #set($thePage = $pageManager.getPage($contentID))

        #if($contentID == $currentPageID)

            #if($thePage.getParent())

                #set($breadcrumbsAsHtml = "<span class='BCtoggle' title='Click to View Full Breadcrumb Path'>...</span><span style='bold'>" + $thePage.getTitle() + "</span>" + $breadcrumbsAsHtml )

            #else

                ##Ignore if this page is the home page

            #end

        #else

            #set($breadcrumbsAsHtml = "<a href='"+$thePage.getUrlPath()+"'>" + $thePage.getTitle()+ "</a>" + $breadcrumbsAsHtml )

        #end

   

    ## Does this iteration have a parent?

    #if($thePage.getParent())

        #set($breadcrumbsAsHtml = $breadcrumbsAsHtml)

       

        ## Get parent of this iteration

        #getBreadcrumbs($thePage.getParent().getContentId().asLong())

    #end

#end

<style>

.BreadCrumbles a:not(:first-child) {display:none;}

.BreadCrumbles a {position:relative}

.BreadCrumbles a:after {

    content:' \\ ';

}

.BreadCrumbles .BCtoggle {

    font-size: 22px;

    font-weight: bold;

    line-height: 6px;

    padding: 0px 4px;

    background: #fff;

    display: inline-block;

    vertical-align: middle;

    height: 18px;

    border-radius: 6px;

    margin: 0 6px;

    border: 2px solid #ccc;

    cursor:pointer;

    transition:all .3s ease-in-out;

}

.BreadCrumbles .BCtoggle:hover{

    background:#e0e0e0;

}

.BreadCrumbles .BCtoggle.closeBC {

    line-height: 16px;

    font-family: monospace;

}

</style>

<script>

    AJS.toInit(function(){

        AJS.$('.BreadCrumbles .BCtoggle').click(function(){

            AJS.$('.BreadCrumbles a:not(:first-child)').toggle();

            AJS.$(this).text(AJS.$(this).text() == '...' ? ' < ' : '...');

            AJS.$(this).toggleClass('closeBC');

        });

    });

</script>

##Template: ----End code
0 votes
mykhailo m August 15, 2021

@david Chevreau 

I created request for feature (for Cloud Confluence), but as I understand, unfortunately, we will wait for it for ages...

https://jira.atlassian.com/browse/CONFCLOUD-72601 

If that is what you have expected, then you may vote for this feature...

If you need it for Stand alone version, you may have a look on macro, but I think it has to be modified... to provided breadcrumbs link for linked page.

https://community.atlassian.com/t5/Confluence-questions/How-can-I-create-a-Confluence-user-macro-that-displays-the-full/qaq-p/937886

## @noparams

#set($breadcrumbs = "")
#set($breadcrumbSeperator = " / ")

#getBreadcrumbs($content.id)

$breadcrumbs

##recursive macro to get the path to page breadcrumbs
#macro( getBreadcrumbs $contentID )
    #set($thePage = $pageManager.getPage($contentID))
    
    #set($breadcrumbs = $thePage.getTitle() + $breadcrumbs)
    
    ## Does this iteration have a parent?
    #if($thePage.getParent())
        #set($breadcrumbs = $breadcrumbSeperator + $breadcrumbs)
        
        ## Get parent of this iteration
        #getBreadcrumbs($thePage.getParent().getContentId().asLong())
    #end
#end

Best wishes,

Mykhailo

david Chevreau
Contributor
August 16, 2021

Thank you.

I voted !

 

I looked in macros, but it seems too time consuming for me to learn it and install the sdk.

Another thanks for this macro.

0 votes
Nic Brough -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.
August 9, 2021

Yes, when you're writing, use the link function (shortcut is a square bracket on server) - it'll ask you for a space and a page name.  (The space is optional, it assumes "the current space" if you don't specify one)

david Chevreau
Contributor
August 9, 2021

thanks. I add details below to my question.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events