chipplechipple

Blog - MT archives renamed

Technology MT archives renamed

Sorry about the amount of technical posts lately...

After having been wanting to do so for a while, yesterday I finally changed my MovableType archives folder/filename pattern.

Individual entry pages
Before: http://www.chipple.net/mt/archives/001817.php
After: http://www.chipple.net/mt/2005/02/14_001817.php

Monthly pages
Before: http://www.chipple.net/mt/archives/2005_02.php
After: http://www.chipple.net/mt/2005/02/ (index.php optional)

I had always been using the MT 2.6x default style, but I had been getting tired of having all the files in the same folder, and also I felt like I didn't need that useless "archives" folder (the whole blog is an archive anyway) which I had initially put in because of the MT example.

A great advantage of the new format is that the site's URLs are now more "hackable" than ever, you can get rid of the filename to see the monthly index, and I've even added a yearly index (not a MT feature) which shows a list of all titles.

http://www.chipple.net/mt/2005/02/14_001817.php
http://www.chipple.net/mt/2005/02/
http://www.chipple.net/mt/2005/
http://www.chipple.net/mt/

This morning I was just telling someone that I'm against link rot (URLs going dead), and indeed I made sure that all old URLs redirect to new ones.

Q. Why not give the day its own folder too? (2005/02/14/001814.php)
A. I don't usually post many times a day, and I don't like folders with just one or two files, so it just wouldn't fit my blogging style. I like having the day in the URL though. I could still make the URLs look that way with .htaccess but that part wouldn't be hackable since I don't have or want daily archives.

Q. Why not put the dirified title in the filename instead of the ID? (2005/02/14_fugo_keiji.php)
A. I tend to like unique IDs, and as I sometimes change titles on an entry a few times, it would probably just make a mess. :)

Posted on February 26, 2005 at 11:21 | Tweet |


Trackback


Comments RSS

I was thinking about the doing the exact same thing before but was just too lazy. Now you got me thinking again. Does this make upgrading more difficult? I'm assuming you had to make some changes to files..

Posted by Roy on February 27, 2005 at 06:46


The only changes to templates I had to do were where I build the URLs by myself (in a few PHP scripts) and a few relative paths (like PHP includes in which I used "../../something.php") because the folder depth of my files changed. Otherwise I just changed my archive filename patterns and rebuilt.

Then, to keep my old URLs working, I added this to my .htaccess.

RewriteEngine On
# Individual archives
RewriteRule ^mt/archives/([0-9]{6}).php$ /mt/converturl.php?blog=1&entry=$1 [L]
# Monthly archives
RewriteRule ^mt/archives/([0-9]{4})_([0-9]{2}).php$ /mt/$1/$2/ [R=301,L]

converturl.php is a small script I made that takes the blog ID and entry ID as parameters and redirects to the new style URL with a 301 status (Moved Permanently). To do the redirect I need to get the entry from the MT database and use entry_created_on to add the date parts to the filename.

The same could be done with a .htaccess containing one RedirectRule for each of your entries (which can be created automatically once with a MT template), as suggested elsewhere, but I would guess this wouldn't be too good for performance.

Another solution I saw is to make a redirect page using your template before changing the archive filename pattern, then you rebuild, put your real template in place, change your archive filename pattern, and rebuild again. The inconvenient is that you have to keep these old files forever.

Posted by Patrick on February 27, 2005 at 09:19


Thanks for the tips. I'm tempted to try this out but I know I will screw things up and end up spending the whole week obsessed with it.

Posted by Roy on February 28, 2005 at 21:44


Yeah, I know what you mean. I needed to wait for a moment of high self-confidence. :)

Posted by Patrick on February 28, 2005 at 21:50



« Panikaraqs | Back to main page | You The Rock★ mini-live »