An Introduction to Movable Type’s Template System
Movable Type’s template tags are the key to its publishing power. And the fundamentals of how they work are simple — if you’ve ever done a mail merge in a word processor, or even played a game of Mad Libs, the idea is pretty familiar. At its simplest, you create a regular HTML file (or XML, or plain text, or anything else), and then you tell Movable Type a few places where you’d like it to insert the information that MT manages. Design a beautiful web page that’s designed to have a big title as its header, and then all you have to do is copy that in to MT’s template editor and tell MT, “replace this header text with the title of my entry.”
Of course, you can do a lot more than that with Movable Type’s templating power, and we’ll explain how. To tap into that power, there are two really important key concepts you need to know. The first is that you put information from the MT system into a template using what’s called a template tag. Template tags are like HTML: You put them in a document as special codes, wrapped in angled brackets, and they make the system do something special. Instead of being interpreted by a web browser like HTML tags are, template tags are interpreted by Movable Type itself as instructions to do something smart.
There’s a lot more to it than that, of course. You’ll want to check out the Movable Type Template Tag Overview for full details.
The other key concept you need to know is about Movable Type templates themselves: There are a handful of different kinds of templates. Let’s take a look at what they are:
- Index Templates: These are the simplest templates to understand, since they’re just templates that represent individual documents on your web site. The main home page of your site, the main XML feed for your site — these are like regular files you’d make yourself, but they can use MT’s template tags to include content from your MT blogs.
- Archive Templates: These work like Index templates, but instead of publishing single files, they publish collections of files. That seems complicated, but it’s pretty easy — if you define a Monthly archive, then one will be published for every month that you have entries. If you create a Category archive, then one version of that template’s output will be published for every Category that you put your entries in. And of course, an individual entry archive will be published for every single entry in your system. You can even set up a single archive template to display entries just the way you prefer, and then use it to control how categories and monthly archives are published, but we’ll cover the complicated stuff later.
- Template Modules: Template modules are a little more advanced — they’re little snippets, sections of templates that you can create and then re-use in your other templates. If you’ve ever used “includes” in a website to re-use parts of a page like headers, footers, or navigation, then template modules work the same way. These are handy for creating parts of web pages that you want to keep consistent across your site.
- Widgets: Widgets are like Template Modules, in that they’re little bits of a web page that you can re-use, but you can also manage them with MT’s Widget Manager, a feature that lets you rearrange parts of your page just by dragging Widgets around with your mouse.
- System Templates: These are the most technical kind of templates, as they don’t directly control pages that get published on your site. Instead, they control the display of parts of your site that are produced when a site visitor performs a certain action. For example, if a reader of your site wants to comment, and decides to preview their comment, you can use a System Template to define exactly what the preview page for that comment looks like.
For more detail on the different types of templates, check out Movable Type Template Types.