Semantic weblog posts with Movable Type


A combination of two things - individual archive templates and dynamic pages - allow Movable Type to easily make RDF versions of every post. Now that Piggy Bank is around, this has become very useful: instead of just bookmarking a blog post, a visitor can add the RDF data to their Semantic Bank.

Here's how I got it to work:

  • In Movable Type's Templates menu, check 'Set Each Template's Build Options Separately' and press Save.
  • Create a new template, called 'Individual Entry RDF'.
  • Check 'Enable dynamic building for this template'.
  • Paste in the following template code, adjusting the <dc:creator> fields as necessary:
    <?xml version="1.0" encoding="UTF-8"?>
    	<rss:item rdf:about="<$MTEntryPermalink$>">
    		<dc:date><$MTEntryDate format="%Y-%m-%dT%H:%M:%S"$></dc:date>
    		<dc:title><$MTEntryTitle encode_xml="1"$></dc:title>
    		<content:encoded><$MTEntryBody encode_xml="1"$><$MTEntryMore encode_xml="1"$></content:encoded>
    				<foaf:nick><$MTEntryAuthor encode_xml="1"$></foaf:nick>
                                    <foaf:mbox rdf:resource="mailto:<$MTEntryAuthorEmail$>" />
    		<prism:isPartOf rdf:resource="<$MTBlogURL$>"/>
  • Press Save.
  • Back in the Templates menu, choose 'Edit Archive File Options'.
  • Create a new Template/Archive Type Association:
  • Archive Type: Individual
  • Template: Individual Entry RDF
  • Press Add.
  • In the 'Archive File Template' field for the newly added Individual Entry RDF, put
  • Press 'Save Changes'.
  • Follow the instructions for Enabling Dynamic Publishing...
  • The important steps are to create the 'templates_c' directory (chmod 777) then add this to .htaccess or a .conf file:
    RewriteEngine on
    RewriteCond %{HTTP_REQUEST} ^/archives/.*\.rdf$
    RewriteRule ^(.*)$ /mtview.php [L,QSA]
  • Restart Apache if necessary.
  • Back in the Templates menu, edit the original Individual Entry Archive template to add
    <link rel="alternate" type="application/rdf+xml" title="This entry in RDF format" href="<$MTBlogArchiveURL$><$MTEntryID pad="1"$>.rdf">
    into the <head> section.
  • Rebuild your site.