Movable Type dynamic pages

| No TrackBacks

Keeping my site up to date

I was having trouble keeping my Projects and Presentation pages up to date. I was always creating new projects, and presentation materials, however I always forgot to update the corresponding pages in Movable Type. I decided to make it easier to keep those pages updated.

The system I use is based on Mod_Include, MultiMarkdown and Movable Type.

Enabling per-directory Server-Side Includes

The first step in this process is to enable server side includes. You can make it so EVERY .html page is parsed for SSI, but that can be a resource drain and cause slow page delivery times. I chose to enable SSI for all .shtml files in just two separate directories on my site.

Apache Config -- Enable SSI

The Apache configuration I use on my site is pretty simple. Here's how I enabled SSI on my /projects/ directory:

    <location /projects/>
        Options +Includes
        AddType text/html .shtml
        AddOutputFilter INCLUDES .shtml
        XBitHack Full

Filesystem tweaks

In order to make Movable Type "create" .shtml files I cheated. I just created symlinks from the index.html file to index.shtml in each location I wanted my SSI to work.

    cd /var/www/blog/projects/
    ln -s index.html index.shtml

Apache Config -- Rewrite Fun

To make the request ALWAYS use the .shtml file I created a simple rewrite rule which invisbly proxied the requests for / and index.html to the proper index.shtml file.

    RewriteEngine On
    # rewrite rule which makes /projects/index.html SSI enabled
    RewriteRule ^/projects/index.html  /projects/index.shtml [P,L]
    RewriteRule ^/projects/$  /projects/index.shtml [P,L]

Create your include

The next step is to actually create an include file which will be what is used when the SSI directive is parsed. As I'm trying to include the contents of a completely different site ( VS I used wget to fetch a copy of that page locally. I did this with a cronjob so the include is always up to date.

    0 0 * * * wget -q -O /var/www/html/blog/projects/projects-include.html

Movable Type page contents

The last step is to actually create an SSI directive in your Movable Type page. Here's the contents of my projects page:

    <p style="margin-top: 0px;">As an opensource advocate I use, and suggest that others use opensource projects.<br />
    Here are a few of my open source projects:
    <!--#include virtual="projects-include.html" -->

That's all there is to it. Now I have a site which keeps up with my projects, and my presentations automatically.

No TrackBacks

TrackBack URL: