skip down to the 13 comments

Revcanonical, a rev=canonical WordPress plugin

UPDATE [15:06 April 14th 2009]

Revcanonical is a WordPress plugin that creates localised shortened urls, and adds support for the rev=canonical link tag.

Revcanonical came about after seeing a post on Mr Willison’s website a few days ago. I’d seen mutterings around the web from Joshua Schachter, Dave Winer and Chris Shiflett about how url shortening services are not great for the web for amongst many reasons, the persistence of the link becomes questionable, because you are relying on that service actually being around in 20 years.

It seems that clever people have taken the conversation further and have actually started to come up with possible solutions. One such solution is rev= canonical, and is the one I liked and hence wanted to implement into my site. In fact, some of the big players have already added rev=canonical to their sites. Flickr, Dopplr and already have pages that use it and there’s even a rev= canonical web service. That’s millions of pages already out there.

By default, once you install the plugin to your WordPress blog, you will get a tag added to the source of your page that will contain a shortened version of the url for the page it sits in.

<link rev="canonical" type="text/html" href="" />

That’s it! You can now, not only use this url in sites like Twitter without having to go via a url shortening service, but services or people that understand the rev=canonical link tag, will be able to use this shortened version over the longer canonical version. For example, Simon has build a great bookmarklet that does just this. You can use it when you are on a url you’d like to share. It will return the shortened version of the url if it’s available, otherwise it will use a shortening service as a last resort. This means that if I go to this page:

And I want to share this link on Twitter for example. The bookmarklet would see I have implemented rev=canonical and would fetch the shortened url.

In fact, you would in reality get this:

as the plugin allows you to add your own shortened domain (and I bought one). It’s up to you though point this new domain to the right place.

So, this means that I still get a short url to share, that works on my website, but also means that it’s persistence is down to me, and not to a 3rd party. It also means that if people to, it redirects to my website, so hopefully there’s a little more trust in the shortened url final destination.

Some final tech bits. It uses a base36 encoded post ID (made sense and was simple to implement) in the shortened url with the letter p to namespace. It also creates a 301 as the general consensus agreed.

Oh and if you use the TweetMe plugin I wrote then I’m just in the process of deploying a new version that will use your localised shortened link if it’s available.

[UPDATE] I’m getting lots of people asking why I went for rev=canonical and not rel=shortlink etc. The truth is no particular reason, other than more people I knew and trusted have gone for the former. There appears to be no definitive correct way yet as far as I can see, so until there is I’ll have to make an executive choice.

There have been 13 responses to this post.

  1. HiMY

    I’ve installed your plugin and viewed the source of a page, and yes I see it:

    But I had to view the source of the page to [humanly] see it.

    When one creates/publishes/edits a new wordpress entry or wordpress page, where does one see the new shortened rev canonical url on wordpress dashboard?

    I’m sure it’s right in front of me…but I just don’t see it.


  2. Duncan

    @HiMY you’re right, it’s only there in the source. I’m building a few extras into the plugin, one of which I think will be a wordpress tag you can add to pages, that will be replaced with the short url. Not sure this will do as you’re requesting but it’s a start. I want to keep the plugin as simple as possible, so you can just install and use without any extra setup, unless you choose.

    You could use the bookmarklet I mention above in the mean while.

  3. Wayne Sutton

    Great plugin but need a little help. So I have domain name but when I put it into the Custom Shortened Domain Name field it doesn’t work to create a new url, What else do I need to do? I do have redirecting to my main domain name

    Any advice?


  4. Duncan


    In order for it to work I had to create an Apache .conf, file with a ProxyPass for that domain, with this basic information in it:

    <VirtualHost *:80>
      ProxyPass /

    Hope this helps.

  5. Frank Haywood

    Hi Duncan,

    Thanks for writing this plugin.

    Before I let my subscribers know about it, I’d like to get it working. ;-)

    I’ve installed and activated it and it’s certainly adding the shortened link to the source, and also the bookmarklet in my browser works too. However when I use the shortened link it results in a 404.


    creates the short link:-

    but that link doesn’t work.

    I can probably work out what’s going on if you could give me a clue as to what I should be looking for. For instance the .htaccess is just the standard WP one and there’re no additional rules.

    I also took a look round the WP database to see if there was anything going on in there, but it all seems unchanged and normal to me, so I’m a little puzzled as to how your plugin does the conversion back from the shortened version to the full URL.

    I’m using WP 2.7.1.

    All the best,

    Frank Haywood.

  6. Duncan

    @Frank, sorry to hear it’s not working for you. If you contact me via duncan [at] whomwah [dot] com, I’ll give you hand in fixing your problem.

  7. Boris Anthony

    Hi Duncan. Thanks for this.
    One suggestion: You really should add the ProxyPass example to the documentation. Merely mentioning it is confusing. I’ve never used ProxyPass before and my approach would have been a Redirect or Rewrite rule. Seeing ProxyPass mentioned made me wonder how you used it, specifically in this case. Found it in the comments here but yeah it really should be in the documentation. :)

  8. Duncan

    @Boris point taken, I’ll add it to any future release of the code. I actually wanted to play down the ProxyPass stuff as it is for advanced users who happen to use Apache, and have access to it’s configuration. Thanks for your comment.

  9. Frank Haywood

    Hi Duncan,

    Sorry for not getting back to you about this. I just noticed there’s a new version, so I upgraded and it now works perfectly.

    Hurrah! ;)



  10. Drew

    Thanks for the excellent plugin!

    One issue, the way to use it in the documents say
    get_revcanonical_shorturl($post->ID); but with the newest code, that function seems to be missing from my plugin, it’s only mentioned in the documents. I instead have used get_revcononical_link($post->ID); and that works as expected.
    Does the document need updated or am I missing something?

  11. Duncan

    @drew, Yeah sorry, the documentation is incorrect and should be as you mention. I have a new release ready to go but was waiting as I was trying to fix problems a few people were having. Thanks for the comment.

  12. Danny

    Hi Duncan

    I’ve installed RevCanonical on my self hosted WordPress 2.8.4 blog & bought a nice short domain to use with it. Trouble is, I’m not sure what to do next. Both domains are hosted on the same server so I don’t believe I need Mod_Proxy (using Litespeed web server which I don’t believe supports Mod_Proxy anyway). Would a rewrite rule suffice?

    All advice appreciated because I’m clueless from this point!!

  13. SueckKanal

    Hack again?!

back to the top