Host Your Own Short URLs

nesting dolls In the past week, the web development community received some news that many believed was inevitable, but came a lot sooner than expected: a major URL shortening service (in this case, tr.im) was shutting down. tr.im has since announced plans to stay in business, but even if they do, this serves as an important warning.

URL shorteners like tr.im have been all the rage since Twitter now famously encouraged us to express ourselves in 140 characters or less. These services take a relatively long URL (like the one you can see in the address bar if you’re reading this in a browser) and generate a teeny, tiny URL that redirects to it, which you can use to save characters when mentioning the link on Twitter.

URL shortening has become a competitive space, with contenders like TinyURL, is.gd, Metamark, ow.ly, Su.pr, thurly, tinyarro.ws, and TweaK. Each of these services offer a different combination of URL length, API support in third-party Twitter clients, URL visit tracking with statistics, and other novel features.

With its five-character host name and solid click stats, tr.im had fared well in the race. But when Twitter endorsed competitor Bit.ly by using it to auto-shorten URLs posted through twitter.com, tr.im faltered. Facing a long slog with no clear way to make money at the end of it, tr.im decided to shut down, and web developers went nuts.

The bright side was that all good URL shortening services send browsers onto the full URL using a permanent redirect (also known as a 301 redirect, after its HTTP response code). That means search engines like Google will follow the redirect to its target and only index that.

But, unlike Google, some people publish a URL without following the redirects. Many bloggers routinely copy shortened URLs from Twitter into blog posts verbatim, so when a URL shortening service like tr.im disappears, those links are broken.

In response to the outcry from developers, tr.im relented, scrapping its plans to, er, scrap the service. tr.im has now pledged to press on as a community-owned service, but without a plan to offset its ongoing hosting costs, tr.im’s public backflip may cost it the race.

In short (no pun intended!), URL shortening services significantly weaken the lattice of hyperlinks that hold the Web together. Developers who want reliable, permanent short links to their stuff need to find a better way to provide them.

The only way to free your short URLs from the risk of another individual breaking them is to generate your own and host them on your site. If you’ve done much server-side development, you can probably sketch out how to code this in your head fairly quickly.

If you aren’t a developer, you can check out some of the URL shortening plugins that have begun popping up. la petite url is a WordPress plugin that will generate short URLs for the posts on your blog automatically. Similar plugins are popping up for most popular blogging platforms and content management systems, but if you can’t find one for your particular publishing platform, Shaun Inman’s just-released Lessn is a solid standalone URL shortener that you can host yourself.

Of course, providing your own short URLs only solves the problem for links that you post yourself. Others may still link to you using fragile, short URLs created using one of the above services.

A proposed solution to this problem is short URL auto-discovery. The idea is you include in the head of your document a tag that advertises the short URL for this page:

<link rel="shorturl"
  href="http://example.com/1234"/>

The latest short URL plugins (including la petite url) will add this tag for you automatically.

In theory, Twitter clients and other software that needs to obtain short URLs will load your document, spot this tag (or the HTTP header equivalent), and use your published short URL rather than generating one using a third-party service.

In practice, although a handful of forward-looking sites are now publishing short URLs using this method, we have yet to see the first widely used application to support short URL auto-discovery. We can probably look forward to this happening soon, but the big win everyone is hoping for is that Twitter itself realizes the value of publisher-supported short URLs and begins using them instead of bit.ly when they are available.

Of course, Twitter could simply disregard URLs for the purpose of the 140-character limit and banish the evils of short URLs forever. Yeah, and monkeys might fly out of my butt.

Win an Annual Membership to Learnable,

SitePoint's Learning Platform

  • Stevie D

    Of course, providing your own short URLs only solves the problem for links that you post yourself. Others may still link to you using fragile, short URLs created using one of the above services

    You can help them by clearly printing the short URL on the page in a highly visible place, so that people can see at a glance that there is a short URL ready for them to use. eg the mapping site streetmap.co.uk has a minified link under the map with all the optional parameters stripped out, and a note saying “Link to this map, copy this address”. It isn’t as short as a tr.im link, but it illustrates the principle nicely.

    Of course, Twitter could simply disregard URLs for the purpose of the 140-character limit and banish the evils of short URLs forever.

    Yes they could, but then they could find themselves overrun with links to, eg, http://i_am_going_to_have_bacon_and_eggs_for_my_tea.com/and_then_i_will_watch_friends_although_its_a_repeat_so_ive_probably_seen_it_before/so_maybe_ill_read_stephen_frys_twitter_feed_and_see_if_hes_using_urls_to_get_around_the_140_character_limit_too

  • Chad

    You forget that the character limit is there because of SMS. Sure, twitter could post links verbatim through its API and on its site, and use Bit.ly for SMS. But

  • http://www.dangrossman.info Dan Grossman

    Twitter’s really mucking up the whole web with the short URLs.

    They should just ignore the length of links, and only send shortened versions (that it can create) when the recipient elected to receive the message by SMS.

    The website and desktop clients can easily handle long links. They can shorten what’s displayed just like forums do (link the trimmed text to the full URL).

  • Jay

    As a WordPress user I am using the Pretty Link plugin for this. It will keep statistics of clicked links, offers a pretty-bar just like Google-image search or digg and cloacking. I am using the paid Pretty Link Pro version which offers more like automatic linking of keywords, automatically making every page of your blog a short link and a Re-tweet badge for visitors who find your post interesting enough to put it on Twitter. A plugin with a real good support, quick fixes if needed en new features appearing frequently. So highly recommended.

    Oh, for an example: rolograaf.nl/glb is pointing to my last post with partypictures

  • Nicole

    Recently I wrote an article series on shortening links for various types of sites. http://blog.websitestyle.com/?p=432

  • Anonymous

    Great article, thanks Kevin

  • flyspirit

    Great article, thanks Kevin

  • Anonymous

    An article about short URLs that doesn’t mention SnipURL is either lazy or just plain ignorant. SnipURL has been around since 2001. Many knockoffs have come and gone, like tr.im. I have 1000s of snippings and have never had any issues.

    For people who run their own sites, sure it makes sense to have their own thing. But to share other links with long hideous URLs it makes a lot of sense to have a bookmark management plus short URL manager like snipurl. They give me a much nicer interface than one-feature sites like tinyurl.

    And I can also just use “http://sn.im” if I am on SnipURL.

    So this sounds like a somewhat lazy article on sitepoint, using the demise of one crappy new kid on an old block (trim) to write a piece that most people who run their own site are quite familiar with.

  • matt_riley

    An article about short URLs that doesn’t mention SnipURL is either lazy or just plain ignorant. SnipURL has been around since 2001. Many knockoffs have come and gone, like tr.im. I have 1000s of snippings and have never had any issues.

    For people who run their own sites, sure it makes sense to have their own thing. But to share other links with long hideous URLs it makes a lot of sense to have a bookmark management plus short URL manager like snipurl. They give me a much nicer interface than one-feature sites like tinyurl.

    And I can also just use “http://sn.im” if I am on SnipURL.

    So this sounds like a somewhat lazy article on sitepoint, using the demise of one crappy new kid on an old block (trim) to write a piece that most people who run their own site are quite familiar with.