Last month, there was quite a bit of discussion around how URL shorteners are bad for the internet, and what we developers and users might be able to do to minimize the potential damage. One big idea was to use HTTP headers and rel(or revrel attribute has been called into service in other areas, namely in defining relationships between people (or to other sites you own or have a profile on), and in telling robots how to treat a link.
The first suggested solution to the short URL problem to get broad exposure was rev=”canonical”, which proposed that a page should define a “reverse” relationship to a given short URL. In other words… “You see that short url over there? well, I’m the canonical version of it, so nyah.” (In my head, web pages are full of attitude. This probably comes from years of having to physically subdue rowdy CSS.)
rev=canonical was picked up by several major sites, and has some traction. When I was looking into the issue myself, thinking about what I wanted to do for this site, I found an alternate recommendation that seemed to make more sense to me.
A Better Way Than The Other Better Way
rel=”shortlink” proposes that a page should define a direct relationship to a shortened URL, or “I’m me, but this little URL here is my shortlink.” I read the supporting arguments for rel=shortlink and agreed with them, so that’s the method I’ve implemented (by way of a modified WordPress plugin) on this site. If you look at the sourcecode on an individual post page, you can find a link tag using rel=shortlink.
Of course, I don’t really want the headache of having to maintain my own URL shortening service, so you’ll also see that I’ve settled on using is.gd to provide my shortlinks.
One benefit of using rel=shortlink (or rev=canonical if you go that route) is that you are, in effect, telling people what your preferred short URL is, so they don’t have to go find or make one on their own. Both of the supporting sites I linked to above provided an example, in the form of bookmarklets, that look at the current page you’re viewing and attempt to find the pre-defined short URL.
Both of these implementations depend on TinyUrl as the fallback shortlink provider, so I decided to combine and modify them to check for both rev=”canonical” and rel=”shortlink”, and to use is.gd as fallback provider if no pre-defined shortlink is available.
Of course, nothing’s easy, so I had to code my own is.gd API proxy to recast the output from is.gd into JSON (since that’s what the original bookmarklets were setup to use, and I’m lazy). So, my new bookmarklet depends on my own server to grab the is.gd link, which just means that i can’t guarantee it will work 100% of the time, be particularly fast, or always be available. Nevertheless, I’m using it daily, and haven’t had a major issue yet.
Here’s the bookmarklet: Get Short Link
Just drag it up to your browser’s bookmark toolbar, then click it when you need the Short URL of the page you’re viewing.