Simple tags

NodeBB Development
  • Hey

    I found these 3 lines in

    tag = tag.trim().toLowerCase();
    tag = tag.replace(/[,\/#!$%\^\*;:{}=_`<>'"~()?\|]/g, '');
    tag = tag.substr(0, meta.config.maximumTagLength || 15).trim();

    These lines create rather simple tags, which are hard to use. We wanna create a set of tags, which the user then can choose from
    Eg. "CHR (CHR. HANSEN HOLDING)". I can see that this decision makes it easy to compare tags afterwards. Are there any other reasons for this? Or could this be changed so that tags are saves as they are written?

    Best regards

  • You can probably remove those restrictions but be careful about what you allow, you most definitely want to run the tag through something like tag = validator.escape(tag) if you are going to allow more characters.

    Also if you don't lowercase tags NODEBB and NodeBB will be different tags.

  • Thanks for the response @baris.

    You are of course right, if I should do this, the tags need to be escaped. Secondly I was thinking along the lines of testing equality of two tags 'nodebb' and 'NodeBB' by comparing them in lower case. So the problem I see there is that if the first added as 'nodebb' then someone come along and creates tag 'NodeBB' then the first tag 'win' so to say even though the second is properly the more correct way.

    And then the question. If I where to make this change, and create a PR on Github, are there any chance this is adopted into the code base. Cause we really don't wanna have to patch our version of the forum before production.

    Best regards.

  • I'm not sure if we want case sensitive tags in core.

    However you can easily create a plugin and replace the entire tag functionality. Then you don't have to do it again after updating to later versions of nodebb.

    For example in your plugin you can replace the entire tag creation functionality with

    var topics = module.parent.require('./topics);
    topics.createTags = function(tags, tid, timestamp, callback) {
    topics.cleanUpTag = function(tag) {
    //apply your tag cleanup
    return tag;

    Another possibility is to add a filter into topics.cleanUpTag so plugins can define their own logic for what they allow.

    The biggest issue to figure out is searching and displaying tags. Right now each tag stores a list of topic ids in tag:<tagname>:topics. So for nodebb its tag:nodebb:topics. Since we lowercase all tags topics tagged with any variation of NodeBB go into the same list. With your approach you won't have all the topics grouped under the same tag because you will have different sorted sets like tag:NodeBB:topics, tag:nodebb:topics, tag:Nodebb:topics and so on. And when a user searches for nodebb they won't necessarily get all the topics.

  • To avoid the database being filled with the same tag in different cases like tag:NodeBB:topics, tag:nodebb:topics, tag:Nodebb:topics and so on, couldn't we then just add tags in topics.createTags as the tag eg. NodeBB was first created. So even though the users types nodebb we still add the original NodeBB or are the other drawbacks to this.

  • Yeah after the first tag is created as NodeBB, whenever a user enters a variation of it you need to check all posibilites if it exists in the database already. Like NoDeBb 🙂

  • I see the predicament. Nasty job to generalize that problem 🙂

  • @h_kirk said:

    I see the predicament. Nasty job to generalize that problem 🙂

    Strtolower solves 100% of issues.

Suggested Topics

  • 0 Votes
    4 Posts

    I still cannot figure it out. I see the tid: in some of the topics, but it's got the topic id in it, not a tag id. I'll buy someone a $100 Amazon (or other) gift card (or $100 worth of ETH/BTC) if they release on github a bulk tagging plugin that allows me to add one or multiple tags to all topics/posts in a category. 🙂 I know it's not much, but I'm not generating any revenue off this site and have limited budget.

  • 0 Votes
    8 Posts

    I have the exact same issue and latest version and theme

  • 0 Votes
    1 Posts


    Have a quick question. Do tags have a timestamp on them in the backend?

    One of my new feature requirements is spotting trending tags and some sort of re-organisation of the tagging system to perhaps give people an alternative way to navigate the forum.

    Just curious...

  • 2 Votes
    14 Posts

    @julian that flag mechanism for posts will be very good.

    We are having huge problems with Google AdSense as its all User generated content and we would love to be able to either

    Hide topics from logged out and normal users
    Hide ads on topics

    On those topics if other users mark it as NSFW, or 18+ tag or flagged as 18+

    This will be a huge help. We need this in core and I m sure many others do need this as well.

    Google is getting very strict with its content policies now.


  • 0 Votes
    6 Posts

    Hooray for forward-thinking 🙂

    Initially, we kicked around the idea of supporting multiple categories per topic (so, more like a "tagging" approach, as opposed to categories).

    In the end, we felt that having a "middle-ground" between statically defined categories and user-defined tags was not a proper compromise (since it ended up not being greater than the sum of its parts), so we stuck with static categories.

    A tagging plugin can be built, of course........