Markdown Powered Blogging for Node.js


I am a web developer – I don't need a CMS, and in fact, I actually quite like handling files and code and stuff. Here's how I implemented the rudimentary blogging engine for this site.

Each article is a named directory within a directory that I've called content. You can see the current state of affairs in the screenshot below:

The 'content' directory

When the node app starts up, it scans this directory to populate itself with content, and does some leg-work like ordering the posts by date.

The folder name doubles up as the url for the post, since the stipulations on urls and filenames are similar. (But I do make sure that the folder names are valid urls).

Each article directory must contain a post.json and stub.jade file. e.g:

Contents of 'the-city-calls' directory

post.json contains post meta data, like the date and title. stub.jade is a jade template for the snippet that will appear on the homepage. Then there is an optional full.jade if the post has its own page, as well as the snippet on the homepage (like this one).

The jade files can of course contain jade markup, so I've got complete control. However, for the most part, I use the markdown: directive to make jade pass my formatted text through the Markdown parser.

This way works really well for me. I have complete control over the markup (cause I'm a control freak like that), and I get to author my posts using Markdown – which is a joy for inline formatting and code snippets. Woop!

Still on the todo list: implement a filter based on article tags on the front-end, so that once the article list gets big, you guys don't have to wade through loads to find what you're looking for.

Let me know what you think, or if you've done anything similar: @bengourley.