KBD

Keith Devens .com

Monday, December 1, 2008 Flag waving
"Yes, it's terribly simple. The good guys are always stalwart and true, the bad guys are easily distinguished by... – Giles (BtVS: Lie to Me)
← SemaphoresLeaving for summer school →

Daily link icon Friday, May 23, 2003

I'm about to update my weblog URLs

I'm about to update my weblog URLs to be identified with a date and a name instead of an ID. I've written a quick script that'll take every post that currently has a title and update it so that it has a name too. The problem is that I'm losing my nice short URLs like this:

http://www.keithdevens.com/weblog/3891

and winding up with post URLs that look like:

http://www.keithdevens.com/weblog/archive/2003/May/15/ExplanationOf...
TheRemainingProblemWithMyStructuredTextParser

Which is just far too long. Though, that should only be for old posts. If I were naming that manually, I'd name it something like:

http://www.keithdevens.com/weblog/archive/2003/May/15/StParserProblem

However, numbers will continue to work like so:

http://www.keithdevens.com/weblog/archive/2003/May/15/3891

What do you think?

← SemaphoresLeaving for summer school →

Comments XML gif

Reverend Jim (http://revjim.net/) wrote:

Will old links be broken?

∴ Reverend Jim | 23-May-2003 5:32pm est | http://revjim.net/ | #2105

Keith (http://www.keithdevens.com/) wrote:

No, old links will just be (permanently) redirected to the new links.

It's kind of funny, actually... I have a script in my CMS that does nothing but translate from old weblog URLs to their replacements, since I've changed URL formats so many times.

Keith | 23-May-2003 5:43pm est | http://www.keithdevens.com/ | #2106

Buddha wrote:

Couldn't you simply use the simple numeric date system and an incrementor ad the link, a la: 20030524-1 or somethign like it. I it would remain short and be equally as descriptive as all your slashing and actual month naming. As far as the actal naming of the post, I am not sure why you would do that if it would be so long. A solution for that is to simply truncate the string to some manageable number of letters, or remove all articles or some other list of words.

∴ Buddha | 24-May-2003 10:13am est | #2107

Keith (http://www.keithdevens.com/) wrote:

Couldn't you simply use the simple numeric date system and an incrementor ad the link, a la: 20030524-1 or somethign like it.

I could, but I'd lose the "directoryness", which is important, because

All point to different parts of the archive, by year, by month, and by day. By the way, I used to have a system sort of like that, and of course, the URLs still work... http://www.keithdevens.com/weblog/2003-05-23. But I chose to move away from it.

As for the incrementor, that's just a pain in the ass to implement. To make a post identified by the order in which it was posted that day... I don't like it for a bunch of reasons. I did consider it, and was figuring out how to make it work while at the same time making the post id work (so, /2003/May/23/3901 and /2003/May/23/01 would both point to this post). So... say numbers less than 100 would point to the order within the day, and numbers greater would always represent a post id. But you can't be absolutely certain that you'll never have more than 99 posts in the day, so you still have to do some checks (not to mention the first 99 posts, though I could choose to start numbering at 100). Plus, what happens if you delete a post? An ID and name still uniquely represent that post, but the order would change. Unless I stored the order in the database when the post is first saved, but the point is that this is all a pain in the butt Smiley. For numeric identifiers (as opposed to names), I just went with keeping the ID and forgetting about an "order within the day" identifier.

As far as the actal naming of the post, I am not sure why you would do that if it would be so long.

Well, everything I do from now on will be short. I'm willing to live with silly long names for old posts. Some are short though. It was really cool to see search engine hits get forwarded from http://www.keithdevens.com/weblog/3715 to http://www.keithdevens.com/weblog/archive/2003/Apr/07/PandaDog

A solution for that is to simply truncate the string to some manageable number of letters, or remove all articles or some other list of words.

The database only stores names up to 50 chars. That's still very long for names, but I tried to find a number that wouldn't cut off the names for too many existing posts (50 only did 8 posts -- 45 did 18, 40 did 45, 35 did 92, 30 did 197, and 25 did 441). I would have chosen 25 or 30 if I were starting from scratch, I think. But, I think the solution I chose was an ok compromise.

Probably the most important reason for the URL change was consistency. Rather than having all my URLs be /weblog/archive/2003... etc. except for my posts, now my individual posts are consistent with that too. Plus, fundamentally, weblog posts should be dated in the URL.

Anyway, that's my rationale.

Keith | 24-May-2003 11:46am est | http://www.keithdevens.com/ | #2108

Keith (http://www.keithdevens.com/) wrote:

Actually, I just updated all the names again and replaced lots of articles and other common words like you suggested. So, for instance, the name of this post went from "ImAboutToUpdateMyWeblogURLs" to "UpdateWeblogURLs". Much better.

Keith | 24-May-2003 9:00pm est | http://www.keithdevens.com/ | #2109

Mean Dean (http://www.healyourchurchwebsite.com) wrote:

Thanks for the tips -- I'm about to do the same.

∴ Mean Dean | 28-May-2003 7:45am est | http://www.healyourchurchwebsite.com | #2116

A.Sleep (http://www.asleep.net/) wrote:

I just did the same and use /CCYY/MM/DD/ as my index where if just CCYY is given all entries for said year will show, if CCYY/MM is given all entries for said month in given year will show, etc. Works very well.

∴ A.Sleep | 29-May-2003 7:44pm est | http://www.asleep.net/ | #2121

Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

December 2008
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
28293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 5 posts

Recent comments XML

new⇒Free image hosting sites

Well, TinyPic has this in its​FAQ:

> Images and videos is in​your accoun...

Keith: Dec 1, 1:13am

Join a NameValueCollection into a querystring in C#

Well with a lamba expression, this​is what I came up​with:

?!code:csharp...

Gustaf Lindqvist: Nov 30, 4:38pm

Why no generic OrderedDictionary?

Check​http://www.codeproject.com/KB/recip​es/GenericOrderedDictionary.aspx?d...

Gabrielk: Nov 27, 6:57am

WhatIsMyIP.com

http://www.thesysteminfo.com is​another good alternate to​whatismp.com... I...

Kripz: Nov 26, 8:51pm

Girls, please don't get breast implants

Actually I think it's sweet when a​man loves a woman whether she's big​or n...

218.186.12.228: Nov 26, 9:40am

Generated in about 0.211s.

(Used 8 db queries)

mobile phone