I’m in the process of converting all links to relative URIs. Well, at least those links that point back to this blog.
Although I don’t know why, I do know when I started using absolute URIs as opposed to relative URIs. The change occurred pretty much unconsciously after I migrated to the new domain, and it certainly became common practice after I changed blogging platforms.
There’s no good explanation for why it happened, but it did.
So why the change?
There are several reasons, one of which is that absolute URIs are skewing some reports I run against the site. They’re seen as valid links that are inbound when in fact they should not be. Sure, that’s an issue with some of the reporting software I’m using, but what’s a guy to do when he likes the reports and statistics they provide but doesn’t like that they don’t know the difference between a link from another site and a link from the site they’re reporting on?
Another important reason has to do with considerations regarding future changes to the site. I’ve already migrated domains once before. Absolute URIs would not make that migration easy because they point to a full web address. Relative URIs, however, make the transition smooth because they point only to a context-sensitive address. As long as the folder and permalink structures remain the same from site to site, migrating relative URIs requires no changes to the links in order to work. Absolute URIs, on the other hand, would need to be edited to point to a new domain.
So keep all of this in mind in case you stumble on a link, photo, or video that no longer works. Such a problem would stem primarily from me screwing up the modification.
And for those interested, here’s what I’m talking about.
Links come in two flavors: absolute and relative. Absolute URIs always work because they include all the information necessary to find what’s being looked for.
An example is this: To get to the “About The Kids” page, you can use “http://www.xenogere.com/about/the-kids/” as the URI. That’s an absolute URI because it includes the entire protocol, domain, and page structure needed to find the right information. That link would work from any site on the web, including this one.
When browsing this blog, however, it’s not necessary to use that entire address because your browser session already has context. That is, it already knows what site it’s on and what protocol is being used. That means I could link to that page by using only the “/about/the-kids/” portion of the address. Your browser already knows it’s on www.xenogere.com using HTTP, so this address would be relative to that context, hence it would automatically be interpreted as pointing to http://www.xenogere.com/about/the-kids/.
As you can see, using relative URIs makes domain changes easier because they don’t affect any of the links. Using absolute URIs also has its advantages, but most of those are relevant only to external resources and not really applicable when being used to link to local resources (on the same site). But that’s a grand generalization since there are times when one is more appropriate than another.
Finally, I have to mention this because it certainly entertained me.
My conversion process is twofold: search for all posts containing the string “www.xenogere.com” and filter from those posts the string “http://www.xenogere.com” before saving them back to the database. Simple enough, right?
Except I’ve only gotten as far as last autumn and already discovered some video and photo posts that didn’t disappear from the search after being updated. Why? Because they included links that had typos like “htp://” and “htttp://” and so on.
But why is that interesting?
Because that means none of the links were working in those posts. At all. For anything. Oops.