How to set default template for home page and child pages
Asked by Ganesh Pandian:

hello friends,

We are working on creating automated templates for each spaces in our confluence.

Requirement is when user Click "Create" or" ... "or "Create child page" . It should redirect to template that we defined.

Could you please suggest any workaround for this ?

Thanks in advance.


Answers:
author: Shannon S
body: Hello Ganesh,

Thank you for contacting us!

You can promote specific templates within individual Spaces. See [Promote templates in the Create dialog](https://confluence.atlassian.com/doc/page-templates-296093785.html#PageTemplates-PromotetemplatesintheCreatedialog) for more details.

If you're looking to change the behavior of the primary **Create** button, then I am afraid this is not possible. There is a feature request for this below:

* [CONFSERVER-53447](https://jira.atlassian.com/browse/CONFSERVER-53447) *Allow to configure behavior of the "Create" button*

As a workaround, a solution is that you could use the [Create from Template Macro](https://confluence.atlassian.com/doc/create-from-template-macro-317196995.html). On any page, you can include this add-on to ensure that users are creating pages from the template that you specify.

If you're comfortable modifying your site using Custom HTML, then there is another solution for you to try. **Please note that this is an unsupported workaround**. This workaround was created by my colleague in 2018, and so it can change slightly with future versions of Confluence. If you have any issues after applying this workaround, you'll want to undo the changes.
> 1. Create a global template (or use existing one) from **General Configuration \> Global Templates and Blueprints \> Add Global Template**   
> 2. After Template is created, edit it, if you have an existing template you want to use, edit that one instead.  
> URL will contain **entityId** of the template, like such:
>
> [http://Confluence_URL/pages/templates2/editpagetemplate.action?entityId=123456](http://confluence_url/pages/templates2/editpagetemplate.action?entityId=123456)
>
> In the example above, **entityId** for my Test template was 123456, yours will be different.
>
> 3. Take a note of the entity ID and go to **Custom HTML** from your **Confluence Administration** page.   
> Click Edit and add bellow script, replace \<numbers\> with **entityId** of the template you wish to use  
>
> ```
> <script>  AJS.toInit(function(){      AJS.$('#quick-create-page-button').attr("href", "/pages/createpage-entervariables.action?templateId=<numbers>&spaceKey=~" + AJS.params.remoteUser);  });</script>
> ```
>
> :warning: If the user does not have a Personal Space created, then the script above will not work, see [How to override quick create page button in Confluence 5.9.x](https://confluence.atlassian.com/confkb/how-to-override-quick-create-page-button-in-confluence-5-9-x-818253227.html)KB for more details.  
> Basically, you need to remove **AJS.params.remoteUser** addition and add space name following **spaceKey** instead of \<space name\> field bellow:  
>
> ```
> <script>  AJS.toInit(function(){      AJS.$('#quick-create-page-button').attr("href", "/pages/createpage-entervariables.action?templateId=<numbers>&spaceKey=<space name>");  });</script>
> ```
>
> 4. Save your **Custom HTML** and test page creation, check if it's working as expected.

Let us know if you have any questions about this.

Regards,

Shannon

comments: author: Nihal Gulati
body: This version works on 9.0.1 Data Center:

```
<script> AJS.toInit(function(){ AJS.$('#quick-create-page-button').attr("href", AJS.$('#quick-create-page-button').attr("href").replace("createpage.action?", "createpage-entervariables.action?templateId=<number>&")); }); </script>
```


Tags: confluence-server

server