Feature Guide to Variables in Variables Knowledge Base | World Anvil
    Learn     Variables

Feature Guide to Variables

Available to the Master subscription tier and above. Upgrade here.


Variables are a technical feature that let you display a piece of content in multiple places by just typing the variable name. For example, you could create a variable called wip with a fully formatted work-in-progress banner and embed it to multiple articles without having to create it again every time. Variables can contain BBCode-formatted text (including images, links, and more) and can also create rich-format tooltips.


1. Create a variable

In this guide, we'll create a variable that will hold the abbreviation for the current era of a world: CE.


To access the variables interface, expand Advanced Tools on the sidebar and then select Variables.


Create a collection

Variables are organized in collections, and you need to create at least one before creating a variable. You will see the collection creation panel in the center of the variables interface. Fill in the fields as such:


  1. Title: this is for your own reference. We'll use "Eras" for this example.
  2. Description: also for your own reference; you can leave it empty.
  3. Prefix: prefixes are used when embedding the variables (more on that later). We'll use era as the collection prefix for this example.

Create the variable

After creating the collection, it will appear at the top of the page. Click on it to access the variable creation panel for that collection. To create a basic variable, fill in the fields as such:


  1. Key: this is what identifies the variable in your world. We'll just use ce for our example.
  2. Title: in simple variables, the title is the displayed text. We'll type in "CE".
  3. Type: we'll leave it in the default "Term, Simple" value for now.
  4. Value: with this type of variable, the value is displayed as a tooltip whem hovering over the variable title. We'll type in "Common Era", but if you don't want a tooltip, you can leave the value empty.

Now, we can embed this variable anywhere to generate a text that says "CE" with a mouse-over tooltip that reads "Common Era".


2. Embed the variable

You can embed the variable as many times as you want:


  1. From the variables page, click the copy button next to the variable name.
  2. Paste it anywhere. For our example, the embed code for our example will look like [var:era-ce].

As a Guild member, you can also use the extended mention system: type an [ open square bracket followed by the variable key and choose from the dropdown!


Using prefixes

If you have a lot of variables sorted into multiple collections, you can organize them with prefixes. Usually, the embed code of a variable looks something like [var:key-username]. But if you use a collection prefix, it will look like [var:prefix-key]. This makes finding variables using the extended mention system much quicker.


3. Edit the variable

The magic of variables is that you can edit them once to update all articles it's embedded in. For example, if we suddenly decided we want to call the current era AD instead of CE, we can edit the variable once instead of having to edit every single article in our world!

  1. Go to the variables interface as usual.
  2. Find the variable in the collection you want to edit.
  3. Make the desired changes. Changes are auto-saved.

The variable's value will be instantly updated everywhere at once!


Variable types

There are other types of variables that let you display different kinds of content. You can choose the type while you create the variable, but you can't change it afterward. These are the types:

  • Term, Advanced: this creates a tooltip like the simple version, but instead it's an advanced tooltip that has full BBCode support.
  • Rendered fragment: this won't create a tooltip. Instead, it will embed the "value" field directly into the article. It also has full BBCode support.
  • Link: type the text you want displayed in the Title field, and a full URL in the Value field to create a link variable.
  • Number: this currenly just displays the number you enter in the value field. It doesn't display any other type of content.
  • JSON Array: this type of variable is currently not implemented yet.

Collection settings

To edit a collection's settings, open it and click on "Open Advanced Options" under the collection's title. These are the options you have:


  • CSV import: if you've previously created a list of variables in CSV (comma-separated values) format, you can mass-import them.
  • JSON URL: this URL might be useful to you if you're creating an app with the API.
  • Collection settings: here you can change the collection's name, description and prefix. Note that if you change the prefix, all embedded variables within the collection will stop working until you update the embed tags!

At the bottom you can find the delete button. Please note that deletion is irreversible! Once you delete a collection, both the collection AND all variables in it will be gone forever.