diff --git a/app/assets/javascripts/discourse/templates/components/tag-list.hbs b/app/assets/javascripts/discourse/templates/components/tag-list.hbs
index ff34843a8..a3e912d26 100644
--- a/app/assets/javascripts/discourse/templates/components/tag-list.hbs
+++ b/app/assets/javascripts/discourse/templates/components/tag-list.hbs
@@ -6,7 +6,11 @@
{{/if}}
{{#each sortedTags as |tag|}}
- {{discourse-tag tag.id}} x {{tag.count}}
+ {{#if tag.count}}
+ {{discourse-tag tag.id}} x {{tag.count}}
+ {{else}}
+ {{discourse-tag tag.id}}
+ {{/if}}
{{/each}}
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index e114dde16..cb79ad13a 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -15,7 +15,11 @@ class TagsController < ::ApplicationController
categories = Category.where("id in (select category_id from category_tags)")
.where("id in (?)", guardian.allowed_category_ids)
.preload(:tags)
- category_tag_counts = categories.map { |c| {id: c.id, tags: self.class.tag_counts_json(Tag.category_tags_by_count_query(c, limit: 300).count)} }
+ category_tag_counts = categories.map do |c|
+ h = Tag.category_tags_by_count_query(c, limit: 300).count
+ h.merge!(c.tags.where.not(name: h.keys).inject({}) { |sum,t| sum[t.name] = 0; sum }) # unused tags
+ {id: c.id, tags: self.class.tag_counts_json(h)}
+ end
tag_counts = self.class.tags_by_count(guardian, limit: 300).count
@tags = self.class.tag_counts_json(tag_counts)