The Benefit of Having Context in URLs

By Deane Barker on June 28, 2005

A long time ago, I reworked the URLs of this site. They used to just be the ID of the entry (a la the default MT URL scheme), but then I decided to get cute and embed the date and title in the URL as well. At the time, I wanted to do this simply because I liked the look of it.

The problem came when I had to change the title of an entry (like this one — I thought up a much better title the day after I posted it; see the second paragraph). I couldn’t without busting the URL. This kind of sucked, so I was determined to change the URL scheme back.

However, I was cleaning up some old posts the other day when I found a great benefit to my current URLs — you can usually always tell what post you’re linking to by just the URL.

A lot of these older entries had one of the old ID-centric URL somewhere in the post (linking to another entry, for example), so I needed to convert them. Problem was, somewhere along the way, my database IDs got changed (I think I did an import or something). So none of these URLs matched up to anything anymore. In some cases I was able to figure out where they were pointed based on the context, but often I wasn’t.

A URL like this…

/archives/000585.html

…tells you exactly nothing if the number doesn’t directly match up to a database record. Whereas a URL like this…

/2005/06/27/DeaneDoesSomeMath.html

…gives you an awful lot to go on.

Of course, this only matters if you change your URL scheme along the way (and if your post IDs get hosed), so maybe the entire problem is invented. Regardless, I think I’m going to keep my current URLs and have a little two-column lookup table triggered by my 404 page into which I can enter old URLs and new URLs in the event I simply have to change the title of an entry.

Gadgetopia

Comments

  1. Don’t forget to mention the search engine aspect. Something like mysite.com/product/productname.html still gets higher merit from search engines compared to mysite.com/store.php?id=4711

Comments are closed. If you have something you really want to say, email editors@gadgetopia.com and we‘ll get it added for you.