Slug Only URLs
A few days ago I posted this question to Mastodon:
Happy Friday!
I have a question for my blogger homies: how do you feel about dates in the path of your blog posts? For example:
/2024/09/here-is-the-slug
If I update content (and the timestamp) then my path changes. Would it be better NOT to have the year and month in the path? Or do you view posts as immutable things that should not change once published? I'm considering eliminating the Y/m part and just having globally unique slugs.
Thoughts?
I’m grateful to those who replied and offered their opinions and insights. Thank you!
One person suggested that the original creation date of a post must be preserved after any edits/updates. I appreciate that this is important, at least is some situations, so I’ll need to think about how I want to handle that.
Another person took the “posts as immutable snapshots” position, and I can certainly appreciate this view, which seems the best argument against changing. In the end, this blog probably won’t have much life beyond my own (but who knows?) and in the meantime it’s mine to do with as I please. I make the rules here. 🤣😆
I decided to pull the trigger and remove the year and month components from the URL path of my blog posts. I already was leaning this way, but the thing that pushed it over the line for me was this question (I’m paraphrasing): “what value does having the date in the URL actually add?” I can’t think of any.
Making the change was easy, but I knew it would break any existing links on RSS feeds, other blogs, social media posts, etc. The best way to deal with this is with server-side redirects, which in weblog.lol requires that I add a manual entry for each of the 175 or so redirects into the configuration file. I might try this at some point, but for now I added some client-side JavaScript to the 404 page:
const url = new String(window.location.href);
const capturingRegex = /\/([0-9][0-9][0-9][0-9])\/([0-9][0-9])\/(.*)/;
const found = url.match(capturingRegex);
if ( found ) {
const newurl = "https://mihobu.lol/" + found[3];
document.location.href = newurl;
}
I hope this will work in most cases. At the very least, it’s an attempt.
Besides, Neato might blow all this up anyway.