Categorized | How To

How To: Movable Type DocHead Template Using Multiblog

One of the benefits of using any template engine is that you can change lots of files all at the same time.It has been a long time since someone has asked for a change which has resulted in me changing hundreds of HTML files.It used to be *fingers crossed* global replaces. Then it was, take a full backup and then *fingers crossed* global replace. It is now, change template. DONE (4 hour movable type rebuilds not counted).The document head is something that you are likely to change on numerous occasions. You might need to change the doctype (or add one). You may decide that there is a better way to link to your stylesheets. You may decide to use conditional comments properly. You may want to include RSS feeds links on every page of your site.You need to make a few decisions in what to contain globally in your document head. By globally I mean what is going to be contained on very single page. Because these changes are to be global changes I have decided to only include certain things.These are:

  1. doctype
  2. html opening tag
  3. head opening tag
  4. meta information (not page specific)
  5. stylesheet links
  6. conditional comments
  7. RSS links
  8. Favicon links
  9. Javascript links

What To Inlcude In A Document Head Template

Doctype

A doctype is something which you should now be adding to all of your pages. This articles does not go in to detail why but you should. You may need to change it occasionally. Why? An obvious real life example is you decide to take the step to move from xhtml transitional to strict. If you follow this method it is a pain-fee 2 second change.

HTML Opening Tag

You’ll need one of these. You can close this off in another template. I suggest footer.

Head Opening Tag

Again this should be inlcluded.

Meta Information (not page specific)

I choose to include certain information on every page. This includes author information and copytight stuff. I do not put page specific meta content such as description and keywords as this should be specific to each page for SEO purposes.

Stylesheet Links

What stylesheets you are linking to and how you are linking to them is something that you may want to change often during the inital build phase. You may decide to inlcude an alternate stylesheet, print stylesheet. 5 seconds DONE.

Conditional Comments

I have chose to inlcude these so I don’t have CSS hacks everywhere. Lots of good reasons to implment conditional comments. And again, it may be something you choose to change at a later date as techniques and methods change.

RSS Links

Forever changing my mind. With a global head template it is just one file to change.

Favicon

Take it or leave it.

Javascript Links

I’ve forever playing with new stuff. With one file to change to add js content in to the head of all html pages it makes a change easy to make (and undo)

How do I create a Document Head Template In Movable Type

  1. Install Multiblog
  2. Create a new template module
  3. Give it a logical name (choose a naming convention for your templates. Pain in the ass to change later).
  4. Decide what you want to include
  5. Paste it in to your module body
  6. Include it on all your pages e.g.
<MTMultiBlog include_blogs="1"><$MTInclude module="DocHead"$></MTMultiBlog>

Example Code

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"  xml:lang="en-GB" lang="en-GB"  dir="ltr"><head><meta http-equiv="Content-Type" content="text/html; charset=<$MTPublishCharset$>" /><meta name="MSSmartTagsPreventParsing" content="true" /><meta name="author" content="Ross Boardman" /><meta name="copyright" content="Copyright (c) 2006 Ross Boardman" /><link rel="stylesheet" href="/css/jj.css" type="text/css"/><!--[if IE]><link rel="stylesheet" href="/css/ie.css" type="text/css" /><![endif]--><link rel="alternate" type="application/atom+xml" title="Atom" href="<$MTBlogURL$>feed/atom.xml" /><link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<$MTBlogURL$>feed/index.xml" /><link href="/favicon.ico" rel="Shortcut Icon" type="image/x-icon" /><script type="text/javascript" src="/js/common.js"></script>

Popularity: 24%

1 Comments For This Post

  1. Jerry Galino Says:

    Good site I “Stumbledupon” it today and gave it a stumble for you.. looking forward to seeing what else you have..later

Leave a Reply

Our Flickr Photos - See all photos

Posh Doner Kebab

Optional Service Charge is added at 10%... WTF?

Claires' bump

IMG_1879

IMG_1877

IMG_1876

Bad Behavior has blocked 76 access attempts in the last 7 days.