What are Content Tokens in SXA

Published on May 16, 2019
content-token
sxa

Did you ever had the need to centralize small portions of text and numbers and reuse those within the content of your site? Things like version numbers, prices or just simple texts like copyrights.

Sure you can enter those within your content and use the search within Sitecore to find all the texts whenever you need to update them. But with SXA this becomes a whole lot easier.

One of the hidden secrets of SXA is called Content Tokens. Content Tokens are essentially content items that have a key and a value and can be referenced in fields on other items. They are stored in the Data folder of your SXA site.

When you have defined a content token you can use it in any single-line text, multi-line text and rich-text field type. Referencing a content token in a single-line and multi-line text field can be done by referencing it using the $(key) notation in your field.

For rich-text fields it's even easier. You can simply click the insert variable button to insert content tokens.

Once the content token has been inserted you can recognize it by the key value and the gray background. In html it's wrapped in a span with some additional attributes.