How inject create date in confluence page title?
Asked by Tony Montana:


Answers:
author: Christian Czaia _Decadis AG_
body: Have a look here: <https://answers.atlassian.com/questions/332522>

You'd have to create a blueprint


author: Davin Studer
body: You could create a template(blank or not) and then use the "create from template" macro. In the macro options for the title put @currentDate. See the below screen capture.

![image2015-1-14 15_43_36.png](https://community.atlassian.com/t5/image/serverpage/image-id/29436iA8615E9F96D7D1E1/image-size/large?v=v2&px=999 "image2015-1-14 15_43_36.png")  
[](https://community.atlassian.com/t5/Confluence-questions/How-inject-create-date-in-confluence-page-title/qaq-p/343794?attachment-id=5948){#link_1188fb330c0291}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/58135/1/image2015-1-14%2015%3A43%3A36.png){#display_1188fb330c0291_0}

comments: author: SABVARX
body: Thank you David for sharing this solution. It works well for us!


author: Mike McNamara
body: I agree, this is better than the accepted solution mentioned which gets into programming and macros.

A template, a page with a Create from Template Macro, and your all set. If you include tags on your template, you can build a children display, essentially like the Meeting Notes page you get on a new space.


author: Nikki Anderson
body: Hi Davin (or anyone who might be able to help).

I have created this macro on a page using the @currentDate feature and it works, but it places the newly created page at the bottom of the list of past pages (also with their current/created dates as titles). It seems the only way to sort is alphabetically and when I toggle the option it puts all the pages in oldest date first to newest last.

How do I get it to default to the top of the list?


author: Kirstin Seidel-Gebert
body: IMHO there is no way to achieve this in an automated way. Correct me if I'm wrong.


author: Nikki Anderson
body: Yeah, no automated way, but I did find this thread from 2016 and am trying it. So far, I put in the code into the Look and Feel--\> Stylesheet, but it didn't work, so perhaps I captured the wrong child id number. Trying again...


author: Nikki Anderson
body: oops forgot to paste the link:  
<https://community.atlassian.com/t5/Confluence-questions/Sorting-order-of-child-pages-in-Confluence/qaq-p/404393>


author: Kirstin Seidel-Gebert
body: Ah, that sounds interesting but could possibly break something else in the page tree.  
Nevertheless, worth a try.

I think it is not about capturing the right child ID number but the right HTML element resp. CSS class to apply this styling to. This depends on your Confluence version and if you have any plugins installed that are affecting the page tree.


author: Nikki Anderson
body: Well, it seems to work! I had left out the last number of the child ID. Now it works! I keep creating new child pages with future dates as the page title/name, and they automatically are put at the top of the list exactly how I wanted. And nothing else so far seems to be messed up from it. While this should be an easy button feature, I'm happy with myself for researching and applying this. :-)


author: Robb Chen-Ware
body: This doesn't seem to be compatible with the new editor in my testing. Anyone else seeing different results?

comments: author: kpink
body: Yes, labels and the page nam are no longer defaulting. I wish we could use the old editor until they fix all the annoying issues with the new one


author: Shanta Nathwani
body: This is close to what I was looking for. I want to populate the title with a specific title, that the user can add to at the time of creation. Right now, when a user creates my template, the title goes blank. I want to be able to generate something like: "Client Page: X", where the user can fill in X with the name of the client.

comments: author: Kirstin Seidel-Gebert
body: Hi Shanta,

I once also had a similar requirement and implemented a user macro that can be inserted as a button to a page.  
Clicking on this button will create a new page below the page that contains the button and will set a specific page title and specific labels that are given with the macro.

If you are interested, I can post the macro code.

Cheers,  
Kirstin


author: Shanta Nathwani
body: I've been able to accomplish that in other areas, especially with the date, but in this case, it's based on a template in new spaces that we create for a new client. I'm actually working on a way to create an entire space template, so the only "button" I really want is "Create this space" and have it create the relevant pages, templates and titles. For the case I posted here, I have no where to put the button.


author: Kirstin Seidel-Gebert
body: Ah, OK. This is something different from what I did. IMHO you will end up with coding (blueprint/plugin).


author: Shanta Nathwani
body: I was headed in that direction anyway. Thanks for the help!


author: Petter Topp
body: Hello Kristin.

I'm a Confluence newbie and are looking to achieve exactly what you solved.

Would be very grateful if You could help me with this.


author: Kirstin Seidel-Gebert
body: Hello Petter,

my macro handles dates and labels. It generates a blogpost title like **\<label\> - Statusreport Woche 14/2020**.

```
## Macro title: SA Blog Post Button
## Macro has a body: No
## Body processing: No macro body
##
## Developed by: Kirstin Seidel-Gebert
## Date created: 22.03.2013
## Installed by: Kirstin Seidel-Gebert
## 19.02.2014 KGE Initialize the blog post title with a combination of
## - customer name (taken from the confluence page title, the macro is embedded in)
## - week and year of the current date 
## 11.03.2014 KGE Remove "system" labels from list of labels
## Atlassian uses the labels for managing the favorites of users. Labels starting with "~" or "my:" are system labels.
## Only add &labelsstring to the URL, if it isn't empty.


## @param Pl:title=Label with page labels|type=boolean|desc=If checked, the blog post automatically gets labeled with all labels of the page the macro was added to.|required=true
## @param Labels:title=Labels|type=string|desc=Enter the additional labels for this new blog post as a comma separated list.|required=false
## @param LinkText:title=Link/Button Text|Level|type=string|desc=Enter the text of the link/button.|required=true

## Get the base URL of Confluence.
#set( $wikibaseurl = "${req.getContextPath()}" )

## Check whether the blog post should be automatically labeled.
#set( $pageLabels = [] )
#set( $pageLabels = $content.getLabels() )

## Add the additional labels.
## --------------------------
#set ( $addLabelsString = "" )
#if ( $paramLabels ) 
#set ( $addLabelsString = $paramLabels )
#end

#if ( $pageLabels && $paramPl )
#foreach ($label in $pageLabels)
#set ( $lstr = $label.toString() )

#if ( $lstr.substring(0,1) != "~" && $lstr.substring(0,3) != "my:" )

## Add comma before adding an additional label (not if empty)
#if ( $addLabelsString != "" )
#set ( $addLabelsString = $addLabelsString + ", " )
#end

## Append Label
#set ( $addLabelsString = $addLabelsString + $label )
#end
#end
#end

## Construct the blog post title.
## ------------------------------

## First get year and week.
#set ( $currentDate = $content.currentDate )
#set ( $year = ${action.dateFormatter.formatGivenString("yyyy", $currentDate)} )
#set ( $week = ${action.dateFormatter.formatGivenString("ww", $currentDate)} )

## Next get the customer name from the page title.
## Initialize $blogTitle
#set ( $blogTitle="<Kundenname> - " )

## Get the page title and split it into words.
#set ( $pageTitle = $content.getTitle() )
#set ( $titleArray = $pageTitle.split(" ") )

## Convert the array of words into a list that can be handled by velocity.
#set ( $titleList = [] )
#foreach ($element in $titleArray)
#set ( $dummy = $titleList.add($element) )
#end

#set ( $blogTitle = $titleList.get(0) + " - Statusreport Woche " + $week + "/" + $year )
## debug <p>$pageTitle</p>

## Insert the button/link.
## -----------------------
<span class="e2e-button">
#if ( $addLabelsString != "" )
<a href='$wikibaseurl/pages/createblogpost.action?spaceKey=$space.key&title=$blogTitle&labelsString=${addLabelsString}'>$paramLinkText</a>
#else
<a href='$wikibaseurl/pages/createblogpost.action?spaceKey=$space.key&title=$blogTitle'>$paramLinkText</a>
#end
</span>
```

The part relating to the date is the following:

```
## First get year and week.
#set ( $currentDate = $content.currentDate )
#set ( $year = ${action.dateFormatter.formatGivenString("yyyy", $currentDate)} )
#set ( $week = ${action.dateFormatter.formatGivenString("ww", $currentDate)} )

[...]

#set ( $blogTitle = $titleList.get(0) + " - Statusreport Woche " + $week + "/" + $year )
```

Hope that helps.  
Cheers,  
Kirstin


author: Petter Topp
body: Thank You very much Kristin I will have a look at it.

Br

Petter


author: Davin Studer
body: [@Kirstin Seidel-Gebert](/t5/user/viewprofilepage/user-id/853361) Love the user macro! Great idea.


author: Kirstin Seidel-Gebert
body: Thanks, Davin. :)


author: EPS Software Engineering AG
body: Hi,

Our Add-on provides default tags like __Current_date__, etc. They can be used within the page title and anywhere on the page; also in macro parameters.

Try our [**Live Examples**](https://focuspro.eps.ch/display/PEPSMarktExample/Marketplace+Examples) (no registration needed).**[](https://marketplace.atlassian.com/plugins/eps.focuspro.PageTreeCreator/server/overview)**

**[Marketplace link: Page Tree Creator](https://marketplace.atlassian.com/plugins/eps.focuspro.PageTreeCreator/server/overview)**.

Regards,   
Stephan


Tags: confluence-administration