Renaissance Ninja

DIY Web: Building with Docpad

Ghost has consistently impressed me so far, and I really like how it works for this little blog in particular. But it’s not the best choice for every web project, because it’s “just a blogging platform.” Still, as I wrote about earlier most sites, including all of mine (currently), do just what I said there: serve content.

And content doesn’t change unless you tell it to (we hope!)—so why put it all into a heavy database and use a dynamic language like PHP to render the page every time a visitor requests it…when the content hasn’t changed since they last visited it?

Of course the clever way around that problem is caching: saving a copy of the web page and serve that up to the user instead of regenerating it each time by pulling the request, querying the database, and finally displaying the resulting page. On Wordpress you could pull this off with a tool like Varnish or some plugins (they work, though not as effectively).

Enter Ghost

Now Ghost is smart, and understands the above problem. Ghost is designed to cache all pages and serve those up, rather than generating the content from its (rather small and lightweight) database. In that way it’s a great bridge between the heavy, database-driven, website/application and the lightest of them all: a static site, pure HTML, CSS, and Javascript.

In the process of researching Ghost I ran into the idea of static site generators; then I found Docpad. I was drawn to it because it was built on Node.js, like Ghost, and supported the templating languages I was interested in (Handlebars.js and Markdown*) plus it was powerful enough to power sites that were a bit more complicated than just a blog.

*Writing in Ghost is handled by Markdown, which brought my attention to its awesomeness.

Learning Docpad

The site itself has some great documentation for getting started, and I’ve been poking around the internals now for a little over a week. As someone who’s not super Javascript-savvy it’s been a learning experience already, but not impossibly confusing. The only major obstacle I’ve hit is that I’m not clear on how to use Handlebars as the templating language.

But the default, eco, works just fine and I have a proof of concept blog post page created in it.

So far I’m loving the sheer amount of control one has over the site. Since everything is handled by code you write, then everything can be changed to suit your needs. No butting of heads with existing code, whether in the core or part of a theme. Plus it’s stunningly fast and can support generating dynamic content, if I ever need that in the future.

For one of my site’s this looks like the ideal tool for now, and I’ll be providing updates as I progress with the site design. Right now it’s just a bunch of low-fi wireframes.