Sunday September 5, 2004

Finally Finished!

Good grief, I just spent WAAAAAAAAAY longer than was necessary to complete changes to my blog. I could’ve been done in like 20 minutes, except that I kept typing things in wrong.

Basically, I decided to change my URL style from the default old-style (eg. /archives/000382.html) to new-style CRUFT-FREE (eg. /archives/08/15/entry_title). However, I didn’t want to lose people who have old entries bookmarked or indexed on Google, so I put in a redirect script on all the old entries to automatically take you to the new file structure, as well as alert search engines that the old file should no longer be indexed.

The method of doing this wasn’t that hard—I just published my individual entries as static files using MT tags to structure the entry—since I’m using entry date and title, I just used the appropriate tags. Rebuild, then switch back to dynamic and change file output structure to new way.

Of course, I kept forgetting a “/” or the .html or whatever, so I kept having to rebuild a zillion times. Anyway, I think that’s about all the site tweaking I can handle for one night. Off to bed with me!

UPDATE: I just got a request for specifics on how I did what I did. Well, ask and ye shall receive! I think this could be helpful for many people, and also for myself if I ever need to do this again!

Basically I first backed up all my old files, just in case! Then I did the following steps:

  1. I went to Weblog Config, and then Archive Files. Under Individual Archives I entered <$MTEntryDate format="%Y/%m"$>/<$MTEntryTitle dirify="1"$> in the Archive File Template. Save.
  2. Rebuild all individual archives. This will create files with the new format of month/day/title_of_entry If you have a file extension you want to use, you'll need to put a .html or .php or whatever at the end of the code in the first step.
  3. Go to your templates and edit your Individual Entry Archive Template. Copy all of your current code and store it safely in a text file. You will be temporarily using code and don't want to lose your current layout! Save.
  4. Replace your current template with the following: < ?php $NewUrl = "<$MTEntryDate format="%Y/%m"$>/<$MTEntryTitle dirify="1"$>"; $NewUrl = "http://www.yourURL.com/archives/" . $NewUrl; header("HTTP/1.1 301 Moved Permanently"); header("Location: $NewUrl"); exit(); ?> REMOVE THE SPACE BETWEEN THE "<" AND THE "?php". I only put them in because it didn't show up in the entry otherwise. Save template.
  5. VERY IMPORTANT: Go back to Weblog Config and under Archive files, remove the code you entered in step 1. Save and then rebuild all Individual Entry Files. Failure to do this will cause you to overwrite the work you just did, and you'll have to redo it.
  6. VERY IMPORTANT: Restore your Individual Entry Archive Template back to its original state, using the code you stored safely. Save.
  7. VERY IMPORTANT: Under Weblog Config, replace the code from Step 1 into the Individual Archive File Template. Save.

That's it. Now all entries you write from now on will be posted in the new format. The old files will redirect people to the appropriate new files, and will tell search engines to stop indexing the old pages. After awhile I suppose you could delete the old files to free up space, but being that they only contain a few lines of php code, they don't take up that much room.

Granted you could do this in a different order, saving you a few copy and paste jobs. However, if you were to do the redirect before you had created the files with the new format, then anyone looking for a page in the interim would get an error. It's up to you though, depending on your site traffic and level of sanity. Feel free to make any modifications based on URL structure preference. Also, I use a plugin that let's me substitute keywords in place of the title words. Normally I don't bother with keywords, but it's useful if you have a title with weird characters or if it's extremely long. You could also use the trim_to="15" in the MTEntryTitle tag, if you want to make sure no URLs have titles longer than 15 characters (change to whatever number you like.)

If you have any questions, feel free to contact me and I'll try my best to clarify.

Posted at 11:59 PM | Track comments to this entry vis RSS
8 Comments

After hearing so many people talk about the new MT version, for a while I was tempted to order a copy.

But I’m glad I didn’t. So far WordPress has really exceeded my expectations. And the good news? No rebuilding!

:)

1 | Posted by: Leonieke on September 06, 2004 @ 12:52 PM

Well, there is an option to make only archives dynamic, make everything static, or pick and choose which templates—theoretically you could make EVERYTHING dynamic…and then you’d NEVER rebuild again. I’ve left the indexes as static, but all archives are dynamic. So there is no more rebuilding of individual or date-based archives. MUCH faster….and now that I’m done tweaking, there will be no more rebuilding for me for awhile.

And you could always just download the free version and try it out….you know you want to ;)

WP IS a good program—I just can’t use it until I can do full multi-blog with it, for my Photolog.

2 | Posted by: Jennifer on September 06, 2004 @ 12:55 PM

ooo don’t tempt me! please!

*sigh* I miss my incorporated photoblog ;(

3 | Posted by: Leonieke on September 06, 2004 @ 1:00 PM

btw, I’m blaming you for the fact I’m downloading the free version now :P

so there!

4 | Posted by: Leonieke on September 06, 2004 @ 1:03 PM

oh Nieke, don’t blame Jennifer, as she said, you knew you wanted to :Þ

5 | Posted by: Ivette01 on September 06, 2004 @ 1:46 PM

LOL awesome. *evil laugh*

Lemme know how you think it compares now to WP.

6 | Posted by: Jennifer on September 06, 2004 @ 3:55 PM

right downloaded MT, changed mt.cfg and the password-file, uploaded the entire package ascii/binary, managed to make my sub-directory work.

right, the mt-check.cgi file <- doesn’t run, just shows the contents of the file.

I’ll have to dive into my proxy-program to see if it’s the bad guy, but if it isn’t that’s also the end of my MT adventure.

Will I try again? Mayhaps, who knows :)

7 | Posted by: Leonieke on September 06, 2004 @ 10:44 PM

Can you give more details on how you did the redirects? Maybe an example template. Thanks!

8 | Posted by: tim on September 23, 2004 @ 1:28 PM
Comments for this entry are now closed.

©2002-2008 Jennifer

eXTReMe Tracker