Filename with Underscore or Dash?
03/20/2005
If Movable Type creates an archive file, it converts the entry's title into a filename. With this conversion all blanks from the title are replaced by underscores. But if you want to achieve a good ranking in Google, this is no good replacement. Fortunately the behaviour can be changed.
Factors influencing Google
There are a number of factors that have an influence on the ranking of a page in Google's result lists. Of course the page's content is analyzed with respect to the searched keywords. However, the words appearing in the domain name and the file name also have some influence on the results. Thus, for achieving the best result it is important to know, how Google splits a URL into words. Nobody except Google knows for sure, but it is widely accepted that certain characters inside a URL are regarded as delimiters. Unfortunately the underscore is not one of those delimiters - but the dash is.
This means that Google will not recognize three distinct words in the following filename.
sell_used_cars.htm
Instead Google sees the filename as one long word. And a user seeking for used cars, might not find the URL - at least the page does not win anything from its filename.
The situation changes if dashes are used instead of underscores. Then Google sees three important words in the following filename...
sell-used-cars.htm
...and use them for ranking issues.
Dashes instead of Underscores
So how can we make Movable Type use dashes instead of underscores when creating the filename?
There is no assignment in »mt.cfg« for switching from underscores to dashes. But Movable Type's architecture enables developers to deliver such a function.
A little plugin which can be downloaded for free will help us with our problem. It is the so-called dirifyplus plugin.
The strange name »dirifyplus« results from the function being an extended version of the »dirify« function, which is a public function belonging to the Movable Type base installation. Given an arbitrary name the »dirify« function can create a filename from it.
Installing the Plugin
It is very easy to install the plugin. After having downloaded the plugin from the above location, all you have to do is copy the file »dirifyplus.pl« into the »plugins« directory of your Movable Type installation.
Just by copying this file a function inside it - written in the programming language Perl - is known to Movable Type. Now we only have to take care for the function being called instead of the default dirify function. For this you have to change a template setting. Please proceed as follows.
- Enter your project in Movable Type
- Select the menu item »weblog config« in the left navigation
- Then choose the dialog page »Archive Files«
- For the »Individual Archive« enter the following as the »Archive File Template«
<$MTEntryTitle dirifyplus="pld"$>.html
A screenshot can be found here. And a screenshot for Movable Type v3.2 can be found here.
With this you tell Movable Type to create the filename based on the entry's title. But the title will not be taken unchanged. Instead it is modified by the »dirifyplus« function, which is influenced by the parameter "pld"
- P ... Slashes are removed
- L ... Letters are converted to lowercase
- D ... Blanks are replaced by dashes
Our initial aim will be achieved by the last switch. All blanks will be replaced by a dash character.
The plugin knows a couple of other conversion rules, which are described in the help file.
mgs | 03/20/2005
Feedback is welcome!
What do you think about this entry? Was it interesting or boring? I would like to hear your comments. If the text was helpful, please consider setting a link to http://www.movable-type-weblog.com/.
No spam please!
For protecting this weblog I have installed the MT-Approval Plugin. You have to view a new comment in preview mode, before it is saved on the server. Moreover, I will view your comment manually, before it is published. You can find more information on the subject in the entry Weblog Spamming Basics.
With an active TypeKey session, your comment will be published immediately.
Post a new comment
TypeKey has temporarily been disabled at this location. Please create your comment without using TypeKey or log in from the preview dialog.
Comment
Roland Nyns | May 11, 2005 09:01 AM
Hello,
Thanks for this useful website (oops, sorry, "blog"). I've just discovered MT 2 days ago, and it does need some explanation, though it seems a really good application.
Reading this entry on dirify, it is not clear to me where the line <$MTEntryTitle dirifyplus="pld"$>.html is to be inserted.
Is it meant to replace another line? If so which?
Is it meant to be pasted into the or the and if so where?
Thanks for an answer, and keep up the good work.
Roland.
Hello Roland,
I created a screenshot. A link has been inserted into the entry.
Michael G. Schneider
Comment
Arvind | June 25, 2005 10:15 AM
For PHP ports of DirifyPlus see this post: http://www.movalog.com/archives/dynamic/php-dirification/
Comment
Josh | June 29, 2005 10:25 PM
Excellent breakdown of dirification!
Unfortunately, it seems the link to download the plugin is broken.
I tried movalog.com's php version but I can't seem to get it to work. All I get is %20 where dashes should be. :(
Do you know what's going on?
Comment
Michael G. Schneider | June 30, 2005 07:36 PM
Hello Josh,
I also cannot open the download URL for some hours. I will send the zip file to you by private email.
Michael G. Schneider
Comment
Chris | July 5, 2005 12:50 PM
Hi Michael,
I cannot download the DirifyPlus plug-in. Can you please forward to me via email? I would greatly appreciate it!
Many thanks in advance for your help and thank you for writing the helpful tutorial you did!
Comment
alixky | October 31, 2005 04:49 PM
in new version 3.2 there is quite different from your screen shot. Could you please help in this issue? I couldn't find the archive file name in the template.
Comment
alixky | October 31, 2005 05:00 PM
:) Actually, I already fingured how to do it in the new version: Setting-->Publishing-->Archive Maping-->Individual Entry Archive-->Custom with "%y/%m/.html"
Thank you very much and I hope this comment is useful for others who had the same problems.
Comment
Michael G. Schneider | October 31, 2005 05:18 PM
Alixky, I inserted a screenshot for Movable Type v3.2, too.
Comment
Enoch | November 29, 2005 08:38 PM
Letters are converted to lowercase
Blanks are replaced by dashes
That's exactly how Blogger (Owned by Google) works. Brilliant!
www.mindreality.com

