Download page Work with Variables.
Work with Variables
While Confluence does not officially support variable management, using the Include Page macro, snippets of any size can be included in pages while managed centrally. In combination with Scroll Versions, the more powerful Include+ macro makes these snippets aware of both versions and languages.
Creating a variable
Firstly, you need to create pages that will hold the contents of your variables. This blog post outlines a couple best practices about the use of the Include Page macros for documentation. Here are some essential tips:
- Create the pages to be included on the same hierarchy level as your space's home page. This will hide them from the page tree.
- Use descriptive page names and a prefix identifying the page as one holding a variable. We use a leading _underscore.
- Edit the variable content in different versions and languages for it to be version and language aware.
Using the variable macro
Now, whenever you want to write the name of your variable, insert an Include+ macro and select the page that hols the correct content. You can also copy-paste the macro if you need to use it multiple times.
When including a page from a different versioned or translated space, you would need to first map the versions of the two spaces. Learn more about the cross-space reuse of content in this blog post.
Changing a variable
If your variable changes globally, you can update the content of the macro by editing the page it corresponds to. If the variable changes between versions, changing it in only the new version allows for keeping the old name in the older versions and updating it in the new versions.