|
by Leo A. Notenboom |
It's a fairly common search engine technique to use "meaningful" page names in your URL. "apples.html" is seen by the search engines as more likely to be about apples than, say, "000023.html". Similarly, pages that are at the root of your site may be considered more "important" than those in subdirectories.
My approach at Ask Leo! is to use the article title as the basis for the URL and to place it in the root. Fortunately, MovableType makes both of the steps easy.
First we'll change the location of all the individual archives to be in the root. That's part of the Publishing Settings page in your Weblog Configuration (formerly the Core Setup page in versions prior to 3.2):

Two changes typically need to be made to the default settings:
The Archive Root (the Local Archive Path pre-3.2) needs to be set to the same value as the Site Root (Local Site Path), and
The Archive URL should be set to the same value as the Site URL. Note that the URLs end with a slash while the paths do not.
Now that all the pages are in the same place, we need to change the filenames that MovableType uses to generate them. Further down the Publishing Settings page in your Weblog Config you'll find a section labeled Archive Mapping (or simply the Archive Files page in pre 3.2 versions of MT).
The "Archive File Path" (or "Archive File Template" in pre-3.2) is more correctly thought of as the "archive filename template". Using templating variables, here you can control the filenames that MT will create.

Here you can see that that Individual Entry Archive File Path for Ask Leo! is set to:
<$MTEntryTitle dirify="1"$>.html
This causes MT to use the Entry Title, "dirify" it (an MT function that removes or replaces illegal characters and the like), and append a ".html". So, for example, the pagename for my article entitled "How do I keep my computer safe on the internet?" becomes:
http://ask-leo.com/
how_do_i_keep_my_computer_safe_on_the_internet.html
Warning: there's a catch to this approach, though it's easily solved.
MT does not prevent two entries with the same title from overwriting one another. So if I have two entries with the title "Test" both would get written to "test.html". The most recent one written by MT would "win," and be accessible, the other would disappear from the site (though not MT's database).
In the case of Ask Leo! I've made the conscious decision to avoid duplicate titles. But that's not always possible, or efficient. The solution? Append or prepend the entry ID to the filename using this Individual Entry Archive File Path:
<$MTEntryTitle dirify="1"$>_<$MTEntryID pad="1"$>.html
This uses the title as before, but then appends an underscore, followed by the six-digit entry ID and ".html". Since entry IDs are unique, entries with identical titles will now have distinct filenames. If you have a look at the individual entries at ForwardedFunnies you'll see I've taken this approach there.
Posted December 14, 2006
Site Map
Entire site Copyright © 2003-2008,
Puget Sound Software, LLC and Leo A. Notenboom
Terms, Conditions & Privacy