How should short links be supported in Discourse

If anyone else is not working on it, i would like to work on it, just to be clear, it should work like this right?

  1. I type a url, say
  2. But this link is shortened by the API to
1 Like


Correct, it is tied to the “share” dialog you get to by pressing the link icon on post, or the “Share” button at the bottom of the post.

When that comes up, with your plugin active, it should contain the URL rather than the raw native URL for the topic.

Does it needs to be a plugin?, it will way much easy to implement in core directly,just need to edit 2-3 files only, atm i can add in the core. is that any good?

And does this is also needed?

No, I definitely would not appreciate the forum software randomly shortening my links.

Just use the markdown syntax:

[link title](

link title

Also, the discussion of that should be moved to a new topic.


Love it! Could that be integrated by default meaning any URL cut and paste would auto-magically render to a nice short goog.le URL? Like an option that can be switched on and off but is on by default. Talk about giving your data a break :slight_smile: good stuff.

If this feature is implemented, it definitely needs to be a plugin, and ideally the plugin should allow the admin to select the URL-shortening service to use. I, for one, would not choose Google’s service.


I agree with this. The Drupal Shorten module provides an example of how this can be done. I personally use on my site.

All of these solutions imply using a 3rd party link shortening service. Why using a 3rd party when the discourse app itself could have been used? This could be:, where foo123 is the string id of the topic. I know this is not super shor like, but it is much shorter than the title version.

This requires non-auto-incremental-integer ids for topics. Unlike mysql, postgres is not inefficient when it comes to non integer primary keys. But, rails was written to solve a specific problem: to work with mysql and integer primary keys. And whenever your problem gets deviated from the problem that rails was written to solve, all the magic of rails is replaced with a pile of pain.

Reddit, which is build on postgres, uses random string ids for looking up links. It would be nice to have the same url pattern for discourse.

Another downside of integer ids is that, it exposes some information about your app: I know exactly how many entities your app has.

1 Like

I agree completely. I think this should be the default behavior. If using an external shortening service API is an added feature, that would be great. However, if it’s your own short URL, at least you know it will be up as long as you want it to be.

Because the odds of Google existing in 20 years are fairly high, whereas the odds of your particular Discourse forum existing … isn’t? :wink:

Basically, don’t break links. It’s bad enough that shortening happens at all, which breaks huge swaths of links when a “shortener” inevitably disappears… but the best you can do is rely on a very reliable shortener at the center of the Internet, aka. Google.

Choice is fine, but choosing to create your own “service” is a bad idea.


If your forum is down the point is moot anyway. Choosing one 3rd party over another is a debate regardless of how much faith one has in one particular company. I agree that Google shortening should be an option but is still the service leader.

That’s why I would say offering a built in shortening options is the best route with the ability to use 3rd party APIs like or whatever (maybe via plugins) second.

1 Like is indeed the service leader… of having accounts compromised. :wink:


As I just asked elsewhere: is there an easy way to infer a short URL from the address bar, similar to the /raw/nnn format? e.g. /t/nnn? Did not work when I tried it, but it seems it should address this question of URL shorteners.

I understand the SEO reasons for having the post title in the URL, but for usability it would be nice to be able to get to it directly. I could then also create a shortening domain myself that forwards folks on to my forum URL, e.g. to send people to and on to

1 Like

Use this:

How should short links be supported in Discourse


well, that was quick. :slight_smile: yet another hidden feature! loving the treasure hunt.

thanks much!

FWIW, what you were expecting to work may work in the future.

See also from 8 hrs ago, coincidentally:


Is link shortening possible now? Maybe as a plugin? Would be great for my new project.

What do you get from short links?

I agree it was useful when Twitter included links in the characters count, but now that they don’t, I see no reason to involve a middleman that will break the link once they get out of business…


Even Google got out of the shortlink business, so that’s a bad sign as well.

It seems the only current use for shortlinks is when you expect people to manually type them in, somehow?


Another use is in bulk sms marketing

They share short links over SMS