This guide provides a detailed overview of interpolation keys used for customizing text and system email templates in Discourse.
Required user level: Administrator
While Customizing text in Discourse or Customizing specific email templates you may have noticed that there are placeholder variables available in some templates.
In Discourse we call these Interpolation Keys.
Understanding interpolation keys
Interpolation keys are placeholders available in certain Discourse templates. They allow you to insert dynamic content into your text and email templates.
Example of Interpolation Keys for the Account Created email template:
These keys, such as %{username} or %{site_name} , will be replaced with actual data when the email is sent.
In general, these placeholders can be moved around within the template they belong to, but they are only available in that template and cannot be moved around to different templates, as they are all backed by server code that’s tied to the corresponding template.
However, certain template groups allow additional interpolation keys to be added beyond those already present in the default template.
Additional Interpolation Keys
Welcome User System Message
For system_messages.welcome_user templates, you can add these additional keys:
-
username: The username of the user -
name: The full name of the user -
name_or_username: Either the user’s full name or username
These values are provided by the SystemMessage class at runtime (See system_message.rb for the related Discourse code).
User Notification Emails
For user_notifications and related email templates (including unsubscribe_mailing_list and unsubscribe_link), many additional keys are available, including topic_title, username, site_name, url, unsubscribe_url, and others.
For the complete and up-to-date list of all allowed custom interpolation keys and which template groups they apply to, refer to the ALLOWED_CUSTOM_INTERPOLATION_KEYS in the Discourse source code for translation_override.rb.
Last edited by @SaraDev 2024-07-26T20:16:22Z
Check document
Perform check on document:


