My old install of Movable Type 3 was getting overrun with comment spam, so I decided to start anew with Movable Type 5 in hopes that the spam problem would be fixed out of the box. Unfortunately, it’s not much better than before. I suppose it will, at least, be easier to maintain and upgrade my system from here, and I do get some new goodies like autosave and revision history. I plan to install an extra anti-spam plugin like Comment Challenge if it ever gets updated for MT5. For now, closing comments on all the old entries will help.
Getting Movable Type where I wanted it turned out to be much more of a project than I expected. I’ve documented the following in hopes that it’ll help someone out there.
Putting your blog at the root of your website
Movable Type 5 requires that you create websites that can contain multiple blogs. You can’t have a blog without creating a website first. Your blog URL ends up being something like http://example.com/site/blog/. As I’d think would be a common case, I have only one blog, I want my domain name to point at it directly, and I don’t need the extra idea of a website. The solution I found thanks to this post is to create a website in Movable Type with its root path set to whichever directory your domain name points to, and its URL set to your domain name. Then, create a blog inside it, with its root and URL set to the same respective values as your website’s root and URL. As long as you never publish the website (which would overwrite the blog), it works.
Adding pagination with pretty URLs
When I read a blog, I always want to see the next n entries, not the entries of a specific month (which is how Movable Type’s archive links are displayed by default). Especially if someone blogs only once a month or so, it’s not useful to have monthly archive links.
Movable Type has supported pagination since version 4.3; however, the front-end for it isn’t built into the default themes. A template sample can be found here. By default your page URLs are crufty, and in order to make them clean (e.g. /page/2), you’ll have to modify the pagination code as well as MT’s source.
Replace the 5 lines within the search_link tags in the pagination code with page/. (Save everything that was originally in the search_link tags for the next step.)
In your .htaccess file, you’ll need to rewrite the original search_link value with the new clean URL. The rule would look something like this:
RewriteRule ^page/(.*)$ /mt5/mt-search.cgi?IncludeBlogs=1&template_id=1&limit=7&archive_type=Index&page=$1 [P,L]
Then, find /lib/MT/Template/Tags/Pager.pm in Movable Type’s source. A quick fix (thanks Wolf for the help) is to replace return $link; at line 156 with return "/page/$page";.
Cleaning up entry URLs
This post helped in removing more cruft from my URLs. Basically, you leave the extension fields empty and add some rewrites. I found this Stack Overflow entry useful for redirecting my old blog post URLs to the new style of URL (with hyphens instead of underscores). (I hadn’t actually wanted to convert all my old URLs to use hyphens, but after exporting my old blog and importing it into this new installation, MT had done it for me, and there doesn’t seem to be a way to get around it.)
Better template modules
I don’t like the way Movable Type does templating in its default theme—you still end up repeating a lot of HTML across the various templates. For my site, I created three new templates modules that I used as includes: upperhead, upperbody, and lowerbody. Upperhead has all the HTML of the head down to the title tag. Upperbody contains all the HTML between the body tag and the content. Lowerbody contains everything below the content. With these modules in place, I no longer had to update all 6 index/archive templates every time I made a change to the HTML.
Comments without registration
By default, Movable Type blogs require people to register before they can comment. I’m not a fan of this, so I disabled the registration options. I completely missed the check box labeled “Allow anonymous commenters” as I didn’t expect it on the Registration page, and this plagued me for quite a few hours before I figured it out. So, just FYI :). I’ll also mention that if you require email for comment, you’ll need to add “required” labels to the email (and name) fields in the comment form template yourself, or there’ll be no indication that those fields are required.
That’s it for now! Currently I’m in London for NSConference UK, which together will my Paris visit will likely result in another post or two.
Victoria,
I’d like to say thanks for taking the time to share this experience. I’m going through the process of switching from Blogger to Movable Type 5 and this post answers quite a few of my questions.
As for your template modifications I’d love it if you’d post about that further. That’s the next “daunting” thing on my list, figuring out how to make it look the way I want.
If you keep suffering from comment spam I can recommend inserting the comments form into the page via JavaScript. Since I did that comment spam on my site dropped by almost 100%. Looks like almost all of the spammers simply scan the HTML for the form itself.
Good luck.
Rob—What help do you need with the templates? Are you confused about how the modules work?
ssp—Thanks for the idea :). I’m working on a few different techniques now, may have to update the post once I’m victorious.
Hi, I was searching for paginating MT5 and I found your post.
I have for example http://example.com/news/ http://example.com/blog/
I wan’t clan url like http://example.com/news/page/2 http://example.com/blog/page/2
How would I apply your method on paginating on this type of url?
Note on fighting comment spam:
You might want to read this post first. http://www.movabletips.com/2010/02/fighting-comment-spam-on-movable-type-what-to-do-first.html
What I actually use is this http://disqus.com/ it host your comments and you can customize any way you want, plus I never get comment spam any more.