Confluence does not officially support variable management (although there is currently an open feature request for this for Scroll Versions). However, it is possible to implement a workaround by using user macros that function as placeholders for a variable's name.
- You will require global administrator permissions to follow these steps, as they involve creating and managing user macros.
- Variables managed using this method are NOT version-aware – their names will remain the same regardless of the version of the page where they are included.
- Variables created using this method will be available in all spaces, as the macros used to make them are defined globally.
Creating a variable
Firstly, you need to create a user macro which will function as a placeholder for the variable's name.
The macro should have no body (select No macro body on the Macro Body Processing menu), and should contain the following code:
## @noparams Variablename
where 'Variablename' is the name of the variable.
Using the variable macro
Now, whenever you want to write the name of your variable, insert the macro onto the page:
... and it will appear as though you typed the variable's name out manually:
Changing a variable's name
If the name of your variable changes, you can update the content of the macro by editing the placeholder text (in our example 'Variablename') to reflect the changes.
These changes will be applied in all spaces, as the macro is defined globally.
If we go to the macro editor and change the macro content text to 'Newvariablename':
then everywhere that you have used the macro, the text 'Variablename' will automatically be replaced with 'Newvariablename'.