The Benefit of Having Context in URLs

By Deane Barker

An intelligent URL scheme has usability and technical benefits.

A long time ago, I reworked the URLs of this site. They used to just be the ID of the entry , 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…

The author discusses the benefits of having context in URLs, which were initially implemented to enhance the aesthetics of the site. However, when changing the title of an entry, the URL would not match the title, causing confusion. The author plans to keep the current URLs and use a two-column lookup table for old and new URLs, in case they need to change the title of an Entry.

Generated by Azure AI on June 24, 2024

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 Movable Type 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). But I couldn’t rename it 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.

This is item #284 in a sequence of 357 items.

You can use your left/right arrow keys to navigate