Topic entrance like plugin for tags

Hi, I’m working on my first Discourse plugin.

The idea

We want to alter the tag links behaviour slightly, where, when a tag is clicked anywhere in Discourse, instead of going directly to it, it shows two options; the normal tag url ( or a related (external) page of our choice ( This option would only show for that are in the list.

The list will be in the form of a Ruby array of hashes (or JSON) and this can either be added directly to the plug-in, or be made available at a URL. (The former seems like it will be more resource-friendly - we can just update the list and rebuild the plugin when it updates, as the updates won’t be that often.)

# Ruby array of hashes
array = [
  {forum_tag: "discourse", external_slug: "discourse"},
  {forum_tag: "dc", external_slug: "discourse"},
  {forum_tag: "xenforo", external_slug: "xenforo"},
  {forum_tag: "xf", external_slug: "xenforo"}

# OR

=> "[{\"forum_tag\":\"discourse\",\"external_slug\":\"discourse\"},{\"forum_tag\":\"dc\",\"external_slug\":\"discourse\"},{\"forum_tag\":\"xenforo\",\"external_slug\":\"xenforo\"},{\"forum_tag\":\"xf\",\"external_slug\":\"xenforo\"}]"

We basically want the option to display like when you click on a replies number on the main forum page:

My thoughts

I found 2 methods in Discourse API related to tags:

  1. addTagsHtmlCallback - In this case I would need to set topic.tags to empty array right after assigning its value to other variable. In that way I would prevent rendering tags and can write my custom code.

  2. replaceTagRenderer - The second one allows me to change tag render which does not look so hacky as 1st method.

However please look that in both cases I need to return raw string. From what I found I can’t write and compile Ember template by hand. Obviously I can just render custom links and write a simple function with jQuery putting it to root of app/assets/javascripts, but that’s way different solution comparing to Discourse code.

Am I on the right track? Any/all help will be very much appreciated.


For anyone interested I’m happy to announce a first release of my plugin!

Looking forward for your feedback!


For everyone interested I recommend to check the latest changes especially:

Good … day (?) for everyone!


1 Like

Nice one @Eiji!

We’re hoping to use this plugin on Devtalk… for anyone experienced with Discourse plugins could you take a look to see if any improvements can be made please? We’d appreciate it :blush:

1 Like