Templates and variables
A template is an ordinary Confluence space that a space admin has marked as a template. When someone creates a space from it, Spacewright copies the whole space and replaces placeholders such as {{client}} with the values that person types in.
Turn a space into a template
- Open the space's settings and choose Spacewright template.
- Turn on Offer this space as a template.
- Optionally write a description. People see it when they choose a template.
- Add variables with Add variable, or click Find placeholders in this space to add the ones Spacewright finds.
- Click Save.
Only space admins can change these settings, and a site admin can limit this to some groups. The settings are saved on the space itself. Turning the switch off and saving removes the space from the list of templates.
Write placeholders
Type a placeholder anywhere in a page title or in page text: {{client}}, {{project}}, {{owner}}.
- Names start with a letter or an underscore and may contain letters, digits,
_,.and-, up to 50 characters. - Case does not matter:
{{Client}}and{{client}}are the same variable. - Spaces inside the braces are fine:
{{ client }}. - To keep the braces as text, put a backslash in front:
\{{client}}becomes{{client}}in the new space, unfilled.
Built-in values
These work in every template without being defined:
| Placeholder | Value |
|---|---|
{{space_name}} | The name of the new space |
{{space_key}} | The key of the new space |
{{today}} | The date the copy runs, as YYYY-MM-DD (UTC) |
If you define a variable with one of these names, your value is used instead.
Variable settings
| Setting | What it does |
|---|---|
| Name | The placeholder name, without braces. |
| Label | The question people see on the form (up to 80 characters). |
| Default | Used when the field is left empty (up to 500 characters). |
| Required | The space cannot be created until the field has a value. A default counts as a value. |
A template can have up to 30 variables. Each value can be up to 500 characters.
Find placeholders in this space looks at the titles of the space's top-level pages and of the pages below the home page, and at the text of the home page. In large spaces it checks the first 250 of each. Placeholders that appear only inside other pages' text, or only in pages inside a folder at the top level of the space, are not found: add those variables by hand.
Where values are filled in
Filled in
- Page and blog post titles
- Page text, including tables, panels and code blocks
- Link addresses and smart-link URLs
- Macro parameters
- Expand titles and status labels
- Space page templates copied with the space (name and content)
Not changed
- Labels
- Attachment file names
- @mentions
- The space name and key (you type these on the form)
- Comments (they are not copied)
Create a space from a template
- Open Spacewright and choose the tab New space from template.
- Pick the template. Its description and questions appear.
- Fill in the values. Fields marked * are required; empty fields use their default.
- Enter the name of the new space. Spacewright suggests a key from the name (up to 10 letters and digits). You can change it; Spacewright tells you if the key is already taken.
- Choose what to copy (see copy options) and click Create space.
The space is built in the background. You can follow progress on the same screen or in the Jobs tab. A report page in the new space shows what happened.
Good to know
- Templates are only offered to people who can see the template space.
- Empty values: a placeholder without a value and without a default is left exactly as it is, and the report lists it under Placeholders not filled.
- Title clashes: Confluence needs unique page titles in a space. If two pages would end up with the same title after filling in values, the second gets " (2)" added, and the report notes it.
- Partly formatted placeholders: in pages made with the current Confluence editor, a placeholder that is partly formatted (for example half of it bold) is still filled; the value takes the formatting of the first character. In pages from the legacy editor, a placeholder wrapped in formatting, such as
{{client}}in bold or with only the name in italics, is filled and keeps that formatting. A placeholder broken up by something else (for example a line break), or whose name is only partly formatted, is not filled and the report lists it. Retype such placeholders in the template without formatting. - The template space is never changed by creating spaces from it. Spacewright only reads it.