How can I limit the include page macro to the current space?

We currently have our product releases in their own space with their own inclusion library. After releasing a new version of a product we copy the space with it's own inclusion library to create the next set of documentation for the new release. When one of our employees goes to include a specific page using the include macro the search feature is finding multiple identically named pages for the old inclusion libraries in the now old spaces.

I've tried creating a macro that wraps the include macro but the only option to search for a page is the confluence-content type and that does not have an option to limit the space to just @self.

1 answer

0 votes

it's not exactly what you're after, but you can type in the spacekey first. Also note that if you hover over the page, the link tip can help.

Are you open to build a new plugin/macro? If so you could achieve it by limiting the js search by space.

I've seen the instructions to include the spacekey, but when you add the spacekey the js search stops working. Requiring our users to know the exact title of the page they want to include really slows down their workflow.

I am totally fine creating a plugin or macro but I was unable to find a way to limit the js search by a space. Could you point me in the right direction on how to do that?

Browse to a spaces' blogs, and start searching. you'll notice that the javascript for that is limited to the blogposts in this space. The file that controls this is


In that file is the code snippet for the javascript you're after:

if (spaceBlogSearchQuery.length && confluenceSpaceKey.length) {
        spaceBlogSearchQuery.quicksearch("/json/contentnamesearch.action?type=blogpost&spaceKey=" + 
                AJS("i").html(confluenceSpaceKey.attr("content")).text(), null, {
            dropdownPlacement : quickNavPlacement(spaceBlogSearchQuery)

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Feb 06, 2019 in Confluence

Try out the new editing experience

Hi team, I’m Avinoam, a product manager on Confluence Cloud, and today I’m really excited to let the Community know that all customers can now try out the new editing experience and see some of the ...

1,010 views 51 8
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you