One of the things that’s always bugged me about Movable Type is that there’s no option for the dirify text filter other than underscores. I really dislike underscores in URLs. They get hidden when a link is underlined, some people don’t understand what you mean when you try to spell out a URL with underscores in it, and you have to shift when you type them. Those are all admittedly very minor quibbles, and could even be describe as edge cases, but the fact remains that I don’t like them.

As a result, one of the things that always in the back of my mind when I’m working with Movable Type is “I need to learn how to write plug-ins so I can make a plug-in that offers some other dirify options. If you look in Six Apart’s Movable Type Plug-In Directory, you’ll find DirifyPlus, which boasts sixty different combinations of options for dirifying. Killer! But it doesn’t work with MT3. Nuts.

Then I found Roger Johansson’s post about fixing dirify, which was very nice, but more than I needed. He fixed some problems with non-English characters and he did it by changing the code of Movable Type itself, which I like to avoid.

I decided that I would see how to fix this with a plug-in. It couldn’t be that hard to do something this simple. I went to Arvind Satyanarayan’s impressive and massively useful site Movalog and started to read his plug-in tutorial, when I decided to see if he had already addressed this and I’d some how missed it. He hadn’t solved my exact problem, but he did address it with his post “Cruft-Free URLs”, and there I found my answer. Someone in his comments linked to a plug-in written by Cal Henderson of Flickr fame, called Dashify.

What I like about Dashify is that it’s bone-simple. All it does is give you the option of using dashify="1" instead of dirify="1". But that’s also what I don’t like about it. What I’d really like to have is something that gives me some options about how I’m going to dirify a particular string. Maybe I’d like to use underscores somewhere. I don’t know where, but what I’d really like to see is the option in Movable Type to do something like dirify="1" for underscores and dirify="2" for dashes. Or something similar. DirifyPlus had an interesting system.

Oh, one other thing

In the course of tracking this down, I also found out that Google doesn’t consider underscores in URLs dividers, but it does consider hyphens (dashes) dividers.

Matt Cutts - Dashes vs. underscores
GoogleGuy Confirms that Underscores are not Word Separators
Google test : hyphen and underscore

Those articles are all a year or two old, so Google might have changed that, but I don’t think so. If anyone knows different, let me know. Otherwise, go forth and Dashify! (Thanks, Cal!)

Share this