Tags: category restrictions, tag groups, relationships

(Neil Lalonde) #1

Now that tag support is a core feature of Discourse instead of being a separate plugin, we’ve added some new features around tagging. In this How-To I’ll go through setting up a tag schema like Car Talk uses.

We’ll want to achieve these things:

  • Tags for car makes and car models.
  • Only allow the car make and model tags to be used in certain categories.
  • Car model tags can only be chosen if the matching car make tag is used.

1. Pre-reqs

First, we need to enable tags in the settings:

In a schema where we’re strict about how tags are used, we should prevent most people from creating new tags:

2. Tag Groups

Go to the tags index page (/tags). Choose “Manage Tag Groups” from the top right menu.

Top-level tags

First let’s create the car make tags, which we want people to enter first.

On the tag group page:

  1. Create a new group.
  2. Give it a title.
  3. Add the tags that should belong in the group. You can add existing tags, or create new ones from this page.
  4. We only want people to use one car make tag per topic, so check the box to add this limitation.
  5. Save the group.

Parent-child tag relationships

Now we’ll define the car model tags, which are grouped according to the car makes. There will be one group for each car make.

Create another group as before with an appropriate name. This time we add a parent tag. In this example, we define the Honda car models group, and use honda as the parent tag.

The result

At this point, tagging a topic will obey these rules. When trying to add tags, the first tag can only be one of the car makes (or other tags that have no limitations on where they can be used).

The second tag can be one of the model tags matching the chosen make tag.

3. Category restrictions

If I only want car discussions to happen in a certain category, I can restrict the use of all the car make and model tags from the category settings.

In the “Tags” tab of a category’s settings, add the groups.

If I have other categories where these tags should also be permitted, they can be added in those categories’ settings in the same way.

And that’s it!

Using tags instead of subcategories for a car forum
Categories with allowed Tag Groups
(How) Can we increase the tags limit?
Tagging a topic from email in
Tagging rights for specific users?
I would like to have this scenario in Discourse
How to use tags and tag-groups properly?!
Educating users about tags
How to structure a multilingual community
Large number of forums / categories / groups?
Staff tags missing in settings?
How to create a "tag" button on the top bar?
Kanban Board Theme Component
Tags that are visible to specific tiers
What is a tag group?
(Neil Lalonde) split this topic #2

2 posts were split to a new topic: Can’t use a tag

(Agustin) #4

I know that you can see topics for a given tag, but can you also see all topics for a given tag group? This is in the situation where you aren’t using a parent tag.

(Neil Lalonde) #5

No, there isn’t a way to do that.

(Agustin) #6

How difficult would it be to implement something like that?

Tag-union implementation?
Tags become unusable if used once and then topic is deleted
(Neil Lalonde) #7

We currently have the tag intersection page, so if you don’t have too many tags in a group then you could create a link.

(Agustin) #8

Is there anything like a tag union type page? If not, would the implementation be similar to the intersection page?

(Paula Kreuzer) #9

Do I understand this correctly? It’s currently only possible to restrict tags to a specific category, but it’s not possible to restrict tags for a category? E.g. if I wanted to restrict users from using tags altogether in a specific category would that be possible?

And is there a way to restrict the use of some tags, so only admins & mods can use those tags?

1 Like
(Joshua Rosenfeld) #10

You are correct - there is not currently a way to disable tags in a specific category.

Yes! Search for staff tags in site settings.

(Pad Pors) #11

Is it possible to make “Top-level tags” and “Parent-child tag relationships” distinguishable?

since when the number of child tags increases, it’s hard for the users to follow the tagging relations, and as a result users don’t tag their topics properly.

1 Like
(Pad Pors) #12


Is there any way to show only parent tags in the breadcrumb-drop down menu of home page?

Reason: when the number of tags exceeds a particular number, it’s hard to find tags using the drop down menu (filter) in the homepage. while the number of parent tags can be limited, and it helps to better finding particular topics if the user can also see the parents.

(Neil Lalonde) #13

No there isn’t a way to do that. You could increase the number of tags that show in the filter (max tags in filter list). But if your site has a lot of tags, you probably shouldn’t be using the filter anymore.

(coinyard.org) #15

Good to know.:grinning:

(Nicolas) #16

Hi there,

I’d like to discuss a confusing behaviour I’ve observed while poking around with tags and parent tag (on a hosted instance). Maybe it’s just me, but I’d rather check:

  • I’ve defined a Governance tag group, which contains the pdf_report tag , and which has governance as a parent tag
  • when I create a new topic, the tag auto-complete does yield pdf_report, although I haven’t set the parent tag (me starting to be confused here)
  • upon setting this pdf_report tag and creating the topic , the tag is actually not persisted on the topic (makes sense since parent is missing, but confusing wrt previous topic creation)
  • on editing the topic title, the tag auto-complete no longer suggest the child tag, I need to set the parent first (expected behaviour)

I find this quite confusing from a UX perspective. Is this a known area of improvement ? If I had one suggestion to make, it would be that I do see some value in auto-complete suggesting all possible tags (for user education/awareness), but in case one tag has an explicit parent, then the parent should be set at the same time.

(let me know if screenshots are needed to help with repro of above scenario)

(Neil Lalonde) #17

This sounds like a regression caused by the rewrite of the tags input field. I’ll have a look.

(Neil Lalonde) #18

I found the bug and fixed it. The tag input wasn’t supposed to be showing those tags without the parent tag being present, as you said.

Educating users about tags
(Erlend Sogge Heggen) split this topic #19

A post was split to a new topic: Educating users about tags

(Neil Lalonde) split this topic #20

9 posts were split to a new topic: Questions about creating, uploading, editing tags

Questions about creating, uploading, editing tags