How to specify "parent of the current page" in "create from template" URL?
Asked by Michelle Rau HP:

Hi, I'm wondering if there's a way to specify "parent of the current page" when creating a URL to create a page from a template.

I know it's possible to specify the template and parent page by using this syntax:

https://yourConfluenceAddress/pages/createpage-entervariables.action?templateId=XXXXXXX\&spaceKey=YYYY\&newSpaceKey=YYYY\&fromPageId=ZZZZZZZZ

Is there something I can use instead of "\&fromPageId=ZZZZZZZZ" to specify that the new page from template should be created under whatever page the user is on?

This could help encourage use of the page templates so I would like to know if it's possible. Thanks in advance!


Answers:
author: Monique Khairuliana[ServiceRocket]
body: Hi [@Michelle Rau HP](/t5/user/viewprofilepage/user-id/1142241) , not sure if I'm late to the party but Add page macro from [ServiceRocket's Linking for Confluence](https://marketplace.atlassian.com/apps/166/linking-for-confluence?hosting=server&tab=overview) app creates a link on your page which, when clicked, is equivalent to clicking Create Page button, while at the same time can define the page that you would like to be the parent of the new page, even if it's on a different space.

Check out the documentation here (the function is under the **Parent** parameter)

\* <https://docs.servicerocket.com/linking/macro-reference/add-page>

Hope that helps!

Cheers,  
Monique


author: Alexander Horn
body: Hi Michelle,

try out this code snippets inside your macro:

## [@Param](/t5/user/viewprofilepage/user-id/1345631) PageID:title=Target parent page\|type=int\|required=false\|desc=Select a parent page ID where created pages will be stored as childs. If empty, current page will be assumed.

## Set current page as parent, if not set by user  
#if ( !$paramPageID)  
#set ( $paramPageID = $content.id )  
#end

https://yourConfluenceAddress/pages/createpage-entervariables.action?templateId=XXXXXXX\&spaceKey=YYYY\&newSpaceKey=YYYY\&fromPageId=$paramPageID

best regards

Alex


author: Stephen Sifers
body: Hello Michelle,

This is an interesting idea, to create a template page from the URL formatted with an assigned parent. My ask to understand would be, why are we using a URL instead of allowing the user to select the template which will automatically inherit the parent page?

Additionally, there is the Create from Template Macro which allows you to specify the template and then from a single click create that template within the parent page. Further information on this may be found at [Create from Template Macro](https://confluence.atlassian.com/doc/create-from-template-macro-317196995.html).

We look forward to hearing back.

Regards,  
Stephen Sifers

comments: author: Michelle Rau HP
body: Hi Stephen, I'm back from holidays and I should clarify my question.

1. The use case for using a URL to create a page from template: I can add this link to the sidebar with other space shortcuts, or any place where the "create from template" button cannot be inserted. (Long story short, this helped resolve a squabble between the "child page" and "page tree" fans, since the page tree view doesn't by default include a link to "create a child page." The "new child page" URL points to a specific template I want users to use instead of creating blank pages.)

2. Use case for specifying a specific parent: we are introducing some new forms/templates and we want all pages of the same type housed under the same parent, because that's how our users are browsing for them. For example, if someone wants to create a new page about a specific tool, that page should go under the "toolbox" page.

3. Use case for using a URL that specifies "under the parent page of this page": By default new pages are child pages "under" the current page. A URL like this could create a new page "next to" the current page, i.e. at the same level in the hierarchy.

I hope that helps clarify.

Not to complicate this question, but with that URL syntax, is it possible to create a page in space 1 from a template in space 2 (as long as they're both in the same Confluence wiki)?

![sidebar_links.png](https://community.atlassian.com/t5/image/serverpage/image-id/78093i3E84E2FE4B528AEE/image-size/large?v=v2&px=999 "sidebar_links.png")


author: Stephen Sifers
body: Hello Michelle,

Glad to hear you're back from the holidays. Thank you for your additional clarification and use cases you have, they are very interesting and understandable.

Without using the create from template macro there is an alternative that will require some developer effort. This would be to apply customer javascript to pages and spaces and utilize the REST API or Java API to accomplish your goal. Further information on this may be found at;

* [Confluence Server REST API](https://developer.atlassian.com/server/confluence/confluence-server-rest-api/)
* [Confluence Server Java API reference](https://developer.atlassian.com/server/confluence/java-api-reference/)

An alternative to this would be to browse the marketplace for an app that may accommodate when you're looking for. Here is a preset search within the marketplace for [Atlassian Marketplace \| Template Links](https://marketplace.atlassian.com/search?hosting=server&product=confluence&query=template%20links).

While not a direct answer on how to remove the fromPageId requirement from the URL that you're looking for, I do hope that these references prove helpful.

Regards,  
Stephen Sifers


author: Michelle Rau HP
body: Thank you! Our current system is workable, I'm always trying to find ways to make it easier for users to put the pages in the right place. :-)

I did discover that it's possible to create a page in one space using the template in another. All that's required is the templateId and the destination spaceKey, for example,

[https://mysite.com/confluence/pages/createpage-entervariables.action?templateId=1140916288\&spaceKey=MySpace\&title=New_page](https://mysite.com/confluence/pages/createpage-entervariables.action?templateId=1140916288&spaceKey=MySpace&title=New_page)

This could possibly allow us to build a "template library" that could be used to create pages in different spaces, provided that the templates are self-contained.


Tags: confluence-server

server

template