The Benefit of Having Context in URLs

By Deane Barker 1 min read
Author Description

An intelligent URL scheme has usability and technical benefits.

AI Summary

This post discusses the advantages of incorporating context into URLs, emphasizing how descriptive URLs improve user experience, enhance SEO, and provide clearer navigation. The author illustrates how thoughtful URL structure can benefit both end users and search engines.

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.

Links from this – Smarty as a "Sub-Language" March 21, 2005
I’ve been spending some time working with Smarty lately. This is ostensibly a “templating language” for PHP. But I think it goes beyond that. I assert that Smarty has become a sub-language all by itself.