How to add labels to a page dynamically?
Asked by Lindsey Sullivan:

Hi All -

Is there a way to dynamically add labels to a page in the text? Here are two examples for what I mean:

1. Use a symbol that's not currently used natively by Confluence (eg. #, !) before the proposed tag to create the tag *upon saving the page* . For example:
   1. '**!label1** ' would append the label '**label1** ' to the page upon saving (if using **!** as the *trigger*)
   2. '**#system-testing** ' would create the label '**system-testing** ' upon saving the page (if using **#** as the *trigger*)
2. Use comma separated values entered into a textbox and converting them into page labels (see similar solution in this addon: <https://docs.servicerocket.com/display/SCAF/Adding+Labels+to+Pages+Automatically>)

The usecase for this is to allow our users to easily enter tags in the pages they are creating as they are creating and editing the text. Ultimately, our authors will be creating a new page per project, and each project will have unique categories that will define each project (these categories we will define using labels). Therefore, we can't create a template page (or multiple template pages) that has all the labels predefined, as each page will have different and unpredictable content. We want to encourage our authors to label the pages as they are drafting the content, and the easiest way to do that would be to use a symbol before the label (see in example #1 above).

The key is to allow our users to create the label within the text since the text will be long and detailed, and it will be hard to go back through after drafting it and sifting through the text to find the appropriate labels. We would like to encourage them to create the labels as they are drafting.

Ideally, we would do this using a simple macro as opposed to paying for a pricier add on (ie. in example #2 above), since we don't need every feature this add-on has to offer.

Does anyone know of a native solution, or can help build a macro that would accomplish this? I'm new to macros and plugins so appreciate any help that's offered.

On a side note, as I post this question, the 'Tags' feature below would also be a potentialy helpful solution if it were something we could add-on easily to allow our users to select multiple **visible** and **pre-defined** labels while creating pages. Is this feature available natively in Confluence (I know it's not, but I could be wrong)?

![Screen Shot 2017-07-24 at 10.26.43 AM.png](/t5/image/serverpage/image-id/3516i5032DE62FB296D55/image-size/large?v=v2&px=999 "Screen Shot 2017-07-24 at 10.26.43 AM.png")

Thanks,

Lindsey

PS. Stephen Deutsch (for some reason, I can't tag you), I would love to take you up on your offer to whip up a user macro for this... if it's still on the table 2.5 years later. <https://community.atlassian.com/t5/Confluence-questions/automatically-adding-labels-to-confluence-page/qaq-p/191934>


Answers:
author: Stephen Deutsch
body: Funny, I just happened to see your question. Maybe I'll see what I can do, but it may not be right away.

comments: author: Lindsey Sullivan
body: Much appreciated Stephen! Let me know if I can help. Thanks for responding.


author: Lindsey Sullivan
body: Hey Stephen - any chance you are able to take a look at creating this javascript user macro?


Tags: label

macro

user-macro