Mark Soper's Blog

My New Blog Using Static Website Generator Petrify and Node.js

I've been heads down on a startup for way too long. It's been a great learning experience - a piece about what was learned will be coming soon. Now it's time to move on. I'm looking forward to getting into some new things and back into writing more regularly. This shiny new blog will be a good place to do that.

I made this blog using Petrify, a static site generator based on Node.js. It seems an unusual application of Node, and with Jekyll(Ruby), Hyde(Python), and others being more popular perhaps a bit riskier choice. After digging in to it I found it very well made, satisfying the two major criteria for a static site generator:

  1. Written in a language you like working in (Javascript) so you can enjoy customizing
  2. Makes good choices in key areas like markup language (Markdown) and templates (JSON Templates).

Update: Petrify doesn't have a lot of blogging features - e.g. there doesn't seem to be anything built in that orders articles by date decreasing. This was easy enough to add to the example site's home.js view:

// wait until the navigation and articles views are complete                                                                       
exports.requires = ['navigation', 'articles'];
exports.run = function(view, context){
    // render the home template                                                                                                    
    var html = context.templates['home.jsont'].expand({
            articles: context.data.sort(function(a, b) {
                    return b.date - a.date;
                }),
        partials: context.partials
    });
    view.emit('index.html', html);
};

The blogging main blogging feature it does have, tagging, is handled nicely. In the default configuration the tag menu showed up where I would have wanted in the nav section, tags are nicely associated with articles, and basic pages listing articles under each tag are created automatically and look pretty good. Adding sub-directories for tag and year list pages would make a lot of sense.

blog comments powered by Disqus