Crufty URL cleanup complete
2006-08-16: This 2004 info applies to my earlier blog tool, Movable Type, not necessarily the current one, Textpattern.
Early on in my Movable Type weblog design journey, I let Mark and Anders guide me toward greater website accessibility.
But as time goes on some of these suggestions have gotten long in tooth — Mark himself made some sweeping changes toward “cruft-free URLs” nearly a year ago. What I’ve been most aware of in my configuration to date is how lengthy some of my entries’ permalinks were getting.
Goals
I want to shorten my permalink URLs, and while doing so I might as well also incorporate other changes suggested by Mark et al.:
- Change underscores to hyphens (for more advantageous Googlification)
- Drop filename extensions (a step toward future-proofing against published file format changes)
- Eliminate unnecessary daily archive subcategory (monthly’s enough; I don’t post much)
- Redirect old lengthy permalinks to the spiffy new ones (so incoming Google searchers land on intended page)
Result
before:
http://maikimo.net/mt/archives/2004/06/01/ \
changes_afoot_musings_about_webhosts_blogging_software_freedom.html
after:
http://maikimo.net/mt/archives/2004/06/changes-afoot
How
Shorten filename part of entry permalinks:
Dave’s Short Title Plugin employs square-bracketed keyword(s), if present, as the entry’s short title (or “slug,” the term Mark uses). Non-bracketed keywords continue to function as keywords, which I need for generating related entries.
Install the plugin, then in MT’s Templates > Archiving screen for the weblog under consideration, change the Individual Entry Archive’s Archive File Template format
from<$MTArchiveDate format="%Y/%m/%d"$>/<$MTEntryTitle dirify="1"$>.html
to<$MTArchiveDate format="%Y/%m/%d"$>/<$MTEntryShortTitle dirify="1"$>.html
Change underscores to hyphens:
Use Crys’ DirifyPlus plugin instead of the built-in dirify:
which changes previous result to<$MTArchiveDate format="%Y/%m/%d"$>/<$MTEntryShortTitle dirifyplus="pld"$>.html
(where p = elim all slashes, l = convert to lowercase, d = convert spaces to dashes)
Drop filename extension:
which leads to<$MTArchiveDate format="%Y/%m/%d"$>/<$MTEntryShortTitle dirifyplus="pld"$>
Eliminate unnecessary daily archive subcategory:
which leads finally to<$MTArchiveDate format="%Y/%m"$>/<$MTEntryShortTitle dirifyplus="pld"$>
as the Individual Entry Archive’s Archive File Template format.
Redirect old lengthy permalinks to spiffy new ones:
Use Nathan’s idea to let MT generate the archives/.htaccess that rewrites old URL formats to new. Here’s the .htaccess implementation I came up with (click the Download link). I’m using this as content of a new index template that outputs archives/.htaccess.
I found parsing extension-free files for PHP directives (which I need) requiresForceType application/x-httpd-php
so I put that in there, but it then needs to be overridden with aForceType none
in archives/images/.htaccess and archives/photos/.htaccess to allow graphics to display.
Precedents
I had observed the following:
Mark’s URLs generated by WordPress now look like
http://diveintomark.org/archives/2004/06/18/favorite-jokes
Shelley’s URLs generated by WP look like
http://weblog.burningbird.net/archives/2004/06/21/what-was-interesting/
Default WP permalinks look like
http://maikimo.net/wp/archives/2004/05/16/hello-world/
Default Textpattern clean permalinks look like
http://maikimo.net/txp/article/1/first-post
![[Granny's dinner bell]](http://maikimo.net/images/photolog/IMG_1252.jpg)