David Ruttka

I make computers do things

Updating Octopress to Override the Canonical Rel Link

| Comments

As I’ve continued iterating on the PowerShell script that I’m using to migrate my old WordPress posts, I decided to point the canonical link to the old location. I might choose not to do this once I have a full migration story (redirection of the old permalinks, etc.), but as long as the original location is still up I figure those posts should keep any link juice they have.

So, I can now do this in the yaml on top of a post

canonical: http://thedevstop.wordpress.com/whatever

And the generated post will come out with that in the canonical link, instead of the url for the www.davidruttka.com clone.

<link rel="canonical" href="http://thedevstop.wordpress.com/whatever" />

All it took was a quick edit to the existing capture in the head.html include. The change is the if page.canonical block, and the full line ends up looking like this:

I’ve opened an issue to discuss whether this is something anyone else would ever use. If it is, it should be a simple enough thing to incorporate. I’ve also sent a pull request for the issue, but derped something up and they didn’t get associated.

Later tonight, or tomorrow, I’ll also share what I did to fix the linklog, external_url feature for my instance.