Discourse Templates

:discourse2: Summary Discourse Templates allows the creation of content templates for repeated use. The templates are stored as topics in a special category, where they can be edited and discussed as needed.
:hammer_and_wrench: Repository Link https://github.com/discourse/discourse-templates
:open_book: Install Guide How to install plugins in Discourse

:information_source: This plugin is pretty much a new version of Discourse Canned Replies but it is more flexible and stores the templates in a different way.


This plugin uses a category to store the templates for later use. The first post on each topic of the category will be used as the template for the replies.

This approach provides a lot more functionality then it was available before with discourse-canned-replies as each template will have edit history, can have associated tags, and the subsequent posts can be used to discuss the content of the template if needed.

Only visible topics will be used as templates, so topics unlisted and archived won’t be listed.

The plugin also leverages the category security settings to check which users can use the templates. If the user can read the topics in the category then the option to “insert templates” in the composer will be available to use.

As the user will only be able to see the templates/topics in the categories that they have access, sub-categories can be used to provide different sets of templates to be used to different groups of users.

How to use it

After installing the plugin, you will need to create a category to store the templates.

Notice that every user that has access to read the topics in this category will be able to use the plugin functionality in the composer.

:bulb: Pro-tip: The same settings to edit topics will be applied to “template” topics. If you want that anyone with write access in the category be able to edit the existing templates, you should activate Make new topics wikis by default on the category settings.

After that, specify the category in the plugin settings.

That’s it. Now you only have to create some topics in the specified category and they will be available to use as templates.

If you want you can create sub-categories to better organize the templates or to provide different sets of replies to multiple groups of users.

To insert templates you must first open the reply composer and click the extras button, then select the option “Insert template”

Select the desired template, you can search by text or tags and click on the “paste” icon.

Pre-filled variables

The plugin supports the following variables on the templates:

  • my_username
  • my_name
  • topic_title
  • topic_url
  • original_poster_username
  • original_poster_name
  • reply_to_username
  • reply_to_name
  • last_poster_username
  • reply_to_or_last_poster_username.

All the above variables supports fallback text and will strip out the variable if fallback is not specified and the variable can’t be replaced.

Both title and body supports variable replacement.


Hi %{reply_to_username,fallback:there},



If the reply_to_username is not available, the template will be:

Hi there,


Arpit Jalan

Migration from discourse-canned-replies

There is a rake task to migrate the existing canned replies to templates:

rake "discourse-templates:migrate-from-canned-replies"

This took only a few seconds to to run on Meta to migrate 47 canned replies so it should be safe to use unless you have a staggering amount of canned replies.


The plugin has only two settings:

  • discourse templates enabled: Activates the plugin
  • discourse templates category: Specifies which category stores the templates.


  • extend functionality to other places beyond the composer
  • allow using more than one parent category as template sources

Does the variable replacement support customize variables? And fallback to other variables?


No, only the specified variables are available and it is not possible to fallback to another variable.

What kind of customized variables do you have in mind?


I’d like to use the templates in wiki posts. For example, we have three wikis about the community library and don’t want to repeat ourselves writing down the same field many times and updating it at once.

Like this:

Name: %{name}
Address: %{address}
Opening Hours: %{opening_hours}

Of cause, we could also share the same style in one template.

And I may get your point, allowing the admin to add customized variables to work like other Pre-filled variables also a good idea.


Brilliant plugin! It really takes the canned replies to the next level.

Would you consider adding a couple of variables? These would be very helpful in places / situations where using just a first name is considered much more friendly (and appropriate).

  1. my_first_name
  2. reply_to_first_name

This might be of some help:


Thanks! The feedback has been very positive so far!

We are gathering ideas to improve the plugin to decide what to do next. I can’t say I’ll add them at the moment but I’m definitively taking notes.


Hi, this looks intriguing.

Is there a way it could help me with canned emailed replies to people attempting to sign up to my private forum, when their application has not been accepted? (i.e. they are not yet forum users).

I run a small closed forum for New Zealand architects but regularly get applications from people outside this group or at least from people who have not provided enough information to convince me they belong to this group.

Many but not all such applications are from people I suspect of primarily wanting to market services or products to the group, or to seek an employer willing to sponsor their migration to New Zealand.

My aim with a canned reply is to inform applicants when the application has not been not accepted, to explain (again) what the membership criteria are, and where it seems appropriate, to invite them to try again, supplying further information if they still feel they meet the criteria.

Right now I have to manually cut and paste into the ‘decline application’ / ‘reason’ field every time. Would be much nicer to be able to select from a drop down list of canned responses when rejecting.


I was just about to post about the same thing!!! I want access to the templates for my rejection email.

If you are happy just having a single / simple reply you can edit user_notifications.signup_after_reject.text_body_template in the Customise → Text menu to have a standard reply. You can of course add to this with the reason from the field on the rejection modal.

1 Like

Thanks Nathan

Sadly a single option won’t work for me – I am keen to provide targeted information that will help likely genuine applicants and that is different to what I would send to others.


1 Like

I’ve got it working so that there is a nice template, which I can insert a paragraph into for more targeted information when needed. That isn’t a bad way to do it - not as nice as having a list of canned replies but it is sufficient in most cases.

Here is the text I’m using:

I’m afraid that we have declined your request to join the HiNZ %{site_name}.

We are a community which depends on trust, and we expect those who join to have openly shared their personal details with us. We also expect a genuine interest and/or connection to digital health in Aotearoa NZ.


You are welcome to re-apply, and we encourage you to tell us your reasons for joining in detail when you do. You may also contact us via support@forum.hinz.org.nz to discuss this if you wish.

The eHealth Forum Support Team

1 Like

Thanks Nathan

I might have a play with my template along those lines so that I have a better starting point at least, to modify on a case by case basis


Sadly, it looks like formatting (via BBcode) is lost when the user_notifications.signup_after_reject.text_body_template is edited for use as a canned response.

Doesn’t seem to be the case when pasting the same text/formatting into the ‘reasons’ field in the Delete User dialog.

Am I missing something?

1 Like

Ordinary Markdown formatting codes seem to make it through ok - eg **text** = text

Good enough for my purposes.



This modal? Unfortunately not at the moment. But I’ll keep that in mind. It is surely I nice use case.


I wonder if long term we support a global keyboard shortcut, will be a bit hard to find but catch any text area in discourse

1 Like

There have been a few times I thought of making a template for a chat message.

Hey gang! Time for lunch orders, please check the menu and reply here with your order. Today we are ordering from:

And then I’d drop the link in after :point_up:.

1 Like