Embracing The Power Of Content Tokens In Sitecore SXA

Save Yourself Time and Stress When Authoring

Reusable Content Using Content Tokens

If you're using Sitecore you're already familiar with the ability to reuse components and content itself through data sources. However, there's an even more granular option you should be aware of.

If you're a content author, this approach can save you potentially hundreds of hours in the long run when large amount of content needs to be updated. For example, say your company name changes and you've written that name on every page you have on your site. Or maybe you've mentioned the CEO's name on dozens of pages. It would be mighty stressful and time consuming if you've forgotten where all those mentions are.

Sitecore Content Tokens to the rescue.

Creating A Content Token

Tokens themselves have changed somewhat from Sitecore 9.3 and now in 10.1 (Sitecore SXA 1.9+) are far easier to create, modify and use throughout your content in a variety of ways.

Locate Content Tokens Data Folder

In your SXA site, head on down to the /<Tenant>/<Site>/Data/Content Tokens folder.

Select Content Tokens in the Sitecore SXA content tree

Insert A Content Token

Right click on the folder and insert a Content Token.

Inserting a new Content Tokens in the Sitecore SXA content tree

Here we've created one called "CompanyName". By default, both the Key and Value are set with the same value.

Inputting Key and Value Properties in new Content Token in Sitecore SXA

Let's Update The Value

We can now update the Value field with the name of the company.

Inserting value property in new Content Token in Sitecore SXA

Let's Use It!

Using Content Tokens In Rich Text Editors

Now heres are a couple ways you can go about using that new variable. Open up an item in Experience Editor and open up the Rich Text Editor, or the Rich Text Editor via Content Editor. And look for this symbol. It's called Insert Variable.

Locating the Insert Variable icon in Sitecore SXA's rich text editor

You're now presented with a handy popup allowing you to select the variable you just created! Go on, select it.

Inserting the newly configured content token in Sitecore SXA

We can see it shows up a bit different in the editor.

What the new content token looks like in the Sitecore SXA rich text editor

If we examine the HTML, it looks much different again.

<span class="xa-variable" contenteditable="false" data-variableid="{0212C71E-EFF6-4394-95D2-4A9083C7D87E}">CompanyName</span>

It's clearly a bit more complex, but you can see how it's constructed. This same capability is done in Sitecore 9.3, but there are a few more steps involved which we will cover another time.

Using Content Tokens In Fields

You can also use the Content Token in a field. You're by no means limited to just using it in a Rich Text Editor. And it's really simple to do.

Go to any field with a Single-Line Text field or Multi-Line Text field.

By using the format $(variable name) we can insert that token as needed.

Insert the new content token as needed using $(variable name) in Sitecore SXA

And that's how easy it is. So next time you need to update hundreds of pages, if you've utilized Content Tokens you won't be tearing your hair out because you'll only need to update a single value rather than hundreds or thousands of individual items.

👋 Hey Sitecore Enthusiasts!

Sign up to our bi-weekly newsletter for a bite-sized curation of valuable insight from the Sitecore community.

What’s in it for you?

  • Stay up-to-date with the latest Sitecore news
  • New to Sitecore? Learn tips and tricks to help you navigate this powerful tool
  • Sitecore pro? Expand your skill set and discover troubleshooting tips
  • Browse open careers and opportunities
  • Get a chance to be featured in upcoming editions
  • Learn our secret handshake
  • And more!
Sitecore Snack a newsletter by Fishtank Consulting

Meet David Austin

Development Team Lead


David is a decorated Development Team Lead with Sitecore Technology MVP and Coveo MVP awards, as well as Sitecore CDP & Personalize Certified. He's worked in IT for 25 years; everything ranging from Developer to Business Analyst to Group Lead helping manage everything from Intranet and Internet sites to facility management and application support. David is a dedicated family man who loves to spend time with his girls. He's also an avid photographer and loves to explore new places.

Connect with David