An Introduction to Movable Type Templates

If you’ve installed Movable Type recently, there’s a fair chance you looked at the templates and were immediately overwhelmed. Don’t feel bad, you’re not the only one. By default, MT ships with no less than 56 different templates — all to publish a blog with a single style. You might find yourself asking…

What are MT templates for, anyway?

The templates in Movable Type format the output of your blog. When you write a blog entry and click Publish, MT figures out — based on the date, category, etc. — which of your template files to use in generating new pages on your blog. It reads each template, plugs in the data from your entry, then outputs the new file as part of your blog.

The list of template types in MT.As you poke around in the templates, you’ll find some of them refer to other templates, while still others don’t seem to be used at all. And while this can make MT confusing, it also makes it very powerful. All those templates make customizing your blog much easier.

To understand MT templates, you need to understand the different types and what we use them for. MT templates are all about context. The context of a template determines what MT tags you can use within that template. It’s also possible to establish your own context within a template to customize the output. For example, the <mt:entrytitle> tag only makes sense in the context of an <mt:entries>. The individual entry archive establishes that context automatically. But, if you wanted to put a “Featured Entry” in your sidebar, you would need to create an <mt:entries> context within the sidebar.

We’ll get deeper into this in future posts. For now, just keep in mind that context is important for tags, and templates help to establish that context.

Let’s take a look at the different types of templates:

Index Templates

List of templates in MT.Index templates don’t have a context by default. Instead, you create context within them through the use of container tags. This is a very powerful feature, because it allows you to publish your entries as anything. Index templates are used to produce RSS and Atom feeds for syndicating your blog. You could use one to produce a CSV file that you could import into Excel. Any kind of text file can be generated by index templates — they don’t even need any MT tags in them. You can use them to maintain your CSS and JavaScript files, if you want.

Archive Templates

Archive type options in MT.

Archive templates are used to publish entries and pages, either individually or grouped together based on category, date, or author. How an archive template gets published depends on its type (assigned when you create the template) and the archive mappings associated with it.

Archive Template Types

There are three different types of archive templates. The type of template determines what context the template has when it’s published:

  • Entry – Entry templates are for individual blog entries. They have an <mt:entries> context, which is filtered down to a single entry. You can use tags like <mt:entrytitle>, <mt:entrybody>, and others. Typically, this is the template you’ll use to publish an entry and its comments.
  • Entry Listing – Entry listing templates are for a group of entries. These are your category archives, date-based archives, or author-based archives. They filter the entries to publish based on the archive mapping (more on that in a bit). These templates create a context for tags like <mt:archivelink> and <mt:archivetitle>, as well as more specific tags based on what kind of archive it is.
  • Page – Templates for individual pages. These tend to be very similar to Entry templates, since Pages are just entries that exist outside the flow of the blog.

Before you can publish an archive template, it needs an archive mapping. The mapping tells MT where to publish the files and, in the case of entry listings, what type of archive to publish. An archive template can have multiple mappings. This can be used to publish the same templates in different locations. With entry listings, this allows you to use the same template to publish all your archives — categories, date-based, and authors.

The archive mapping drop-down options in MT.

Template Modules

Template modules are snippets of template code that are called from other templates. If you are familiar with PHP or SSI, think of it as an include. In fact, that’s exactly how you use it:

<mt:include name="Header">

Template modules do not get published on their own, only when they’re included in another template. You use them for pieces of code you want to reuse. They make it easy to have the same header and footer across all your pages, for example. Anytime you find yourself using the same code in multiple templates, it’s a good idea to evaluate whether you should pull that code out and put it into a module.

System Templates

System templates are used for pages that MT has to generate based on an action taken by a reader, such as posting a comment or searching your blog posts. These have their own contexts, and they have a few quirks because of how they’re generated. We’ll explore system templates more in an upcoming post.

Widget set interface.Widgets

Widgets are just template modules, but by declaring them as widgets we can use them in Widget Sets. Widget Sets give us an easy drag and drop interface for customizing our sidebars, footers, and more.

Backup Templates

Sidebar that displays includes and tag information.Backup templates are copies of templates that have been replaced by MT. This can happen if you use the Style Catcher to change the look of your blog, or if you use “Refresh Templates” to restore your templates to the defaults.

I recommend taking a look at the different templates to get an idea of how they’re structured. We’ll go deeper into this in future posts, but for now just try to get a sense of how the different templates are connected. You can do this by opening the templates and looking at the information to the right of the template. This will tell you what template modules and widgets are included in the template, and what MT tags are used. The tags link to the MT documentation, which can be useful for learning what the tags do.

Have a question about MT templates? Let me know in the comments.

  1. By Tedi posted on April 18, 2008 at 4:06 pm
    Want an avatar? Get a gravatar! • You can link to this comment

    Very useful, I like it! TY

  2. By diana posted on September 24, 2008 at 11:17 am
    Want an avatar? Get a gravatar! • You can link to this comment

    I’m grasping at straws asking you this question, because I’ve looked through all the templates looking for what I need to fix a mistake I did on one of the blogs I manage. I’m trying to find the template that would control the “Entry” page (I t hought it was the Entry Summary template, but now I’m not so sure.)

    Basically, I’m trying to move the comments form ABOVE the first comment that’s made. It was originally a custom box, so comments wrapped around it, but I’ll cross that bridge when I come to it.

    Any ideas which template I’m looking for? And if you want to get into specifics, I’d prefer to answer via email, because this is concerning work blogs, of which I don’t want to broadcast the URL’s.


  3. By Ryan posted on May 12, 2009 at 12:42 pm
    Want an avatar? Get a gravatar! • You can link to this comment

    Hi anybody can help? Im still about this. Is there a way to choice what type of archive template to use? Im setting up two entry archive template and I need to use one of them at a certain scenario?

  4. By Robert Barry posted on July 22, 2009 at 6:21 pm
    Want an avatar? Get a gravatar! • You can link to this comment

    Hi. I’d like to direct search-results to a disk file for further processing.
    Is that possible in Movable Type?


  5. By sooran posted on September 15, 2009 at 12:20 pm
    Want an avatar? Get a gravatar! • You can link to this comment

    this post very very helped me !

    Good Time

  6. TrackbackNETTUTS - Web development tutorials and links - Best of the Web - AprilCreating a Print-Friendly Template in Movable Type | DevloungeEditors Choice » An Introduction to Movable Type TemplatesSave Few BucksMovable Type tutorials and resourcesfuncti0n » Movable Type