Config Token
This module allows site builders and developers to create custom tokens that are stored as configuration. This enables these custom tokens to be exported and imported along with other site configuration, making it easier to migrate them between different sites.
Config Token lets you define your own tokens — a support email, a phone number, a promo link — and stores them as configuration instead of in the database.
That one difference is the point of the module. Because your custom tokens are configuration, they are exported, committed and imported exactly like the rest of your site. Define a token on your local site, drush cex, commit, deploy, drush cim — it is on production. No database rows to copy, no re-entering values by hand on every environment, no step that only one person remembers.
Why you might want it
- One place to change a value. A phone number or support address that appears across dozens of nodes, blocks and views becomes a single token. Change it once.
- Content editors do not need to touch code. They type
[config_token:support_email]; you own what it resolves to. - It deploys with your configuration. Tokens move between environments in your normal config workflow, and live in version control where you can review and roll them back.
- Each token has its own text format. One token renders as a real link, another stays plain text — you decide per token.
- Per-domain values. With the Domain module, override any token per domain and the caching follows.
How it works
A config token has two parts, on two tabs of Configuration › System › Config tokens:
- Allowed Config tokens — define the token: machine name, label, description, and the text format its value renders through.
- Config tokens — give each token its value.
Keeping the two apart means the set of available tokens and their values can be managed and deployed independently. Your tokens then appear alongside every other token on the site and work anywhere tokens are supported. To use them in body text, enable Token Filter on a text format and write [config_token:your_token].
Installing the module creates a few example tokens, so there is something working to look at straight away.
Config Token or Token Custom?
Token Custom does the same job but stores its tokens in a custom database table. Deploying a token there means writing rows to that table.
- Choose Token Custom if you want tokens created and edited entirely through the UI on production.
- Choose Config Token if you want your tokens under version control and moving through your environments with the rest of your configuration.
If you have a lot of tokens to create at once, CSV to Config can generate the configuration in bulk.
Requirements
Token. Token Filter is optional and is the usual way to render tokens inside body fields.
Installation
composer require drupal/config_tokenSupported Drupal versions
Drupal 10.3, 11 and 12. The module is tested against all three on every commit.
Depends on
Dependencies of the latest stable release
- Token
- filter Drupal core
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.