I used to use blogging platforms for years and I realized that I used a very few of built-in features. I received a lot of spams in comments that I have to moderate (even with anti-spam plugins). Anyway there are many positive things, they helped me a lot to save time and to push content fast with very user-friendly interfaces. That was my own experience as a user.

So, I decided that I had to make a blog manager that exactly fits my needs:

  1. Very low moderation
  2. Display pages very fast
  3. Template system

Therefore, I have published a new project on GitHub some months ago, calls: blgn. This is a very basic blog generator in Node.js. You can find the whole source code here. Some HTML skills and a little bit of programmation skills are required to handle this tool if you want to create new templates.

  1. blgn architecture
    1. Parser and tokenizer
    2. Template files
    3. User contents and metadata
  2. Output static files for performance
    1. Minifiers
  3. Next steps


Like most of template engines, the structure of blgn is composed with a parser, a tokenizer, an interpreter and especially, a minifier. The particularity is that all user contents are stored in Markdown files in posts or pages folders. Roles of each part are explained below.

Template files can be separated into several files, and each file can be included in another to avoid duplicate code. It also uses metadata inside user content files to indicate associated tags/category, the post’s or the page’s title and date of publication.

Parser and tokenizer

As its name tells, the parser gets templates files and it finds all specific instructions of blgn which starts with % and %. While I am writing this post, the regular expression of instructions is:

%([a-zA-Z_]\w*? ("[^"]+"|[a-zA-Z_][/\w.]*?))+%

The first part is dedicated for an instruction like: print string_or_variableinclude path/to/file or foreach list another_instruction.

All known instructions are treated by the system as tokens: PRINT_TKINCLUDE_TKFOREACH_TK. Then, blgn negotiates commands such as displaying a variable content or a string, including another file and making operations recursively.

Template files

All template files are located in template/ folder. A template contains HTML mixed with blgn instructions. Here is an example of a page that includes other sub-parts:

<!DOCTYPE html>
    %include modules/head.tpl%
        <div id="global">
            %include modules/header.tpl%
            <div class="content">
                <div class="content-middle">
                        %foreach currentPage.tags include modules/tag_item.tpl%
                    <article id="article">
                        %print currentPage.source.html%
            %include modules/footer.tpl%

        <!-- script -->
        %include modules/script.tpl%

User content and metadata

Every user content files are written with Markdown, I mean pages and posts. As blgn aims technical bloggers, that is a wise choice because the structured language is widely used in the developing world. Moreover, it is a pretty user-friendly syntax and HTML could be mixed with it. That is to say, user content files also accept pure HTML. Note that GitHub and Jekyll are using Markdown too. By the way, a lot of resources and tools can be found in GitHub and on the Internet.

Posts and pages have specific metadata on top of each Markdown file. Metadata is written in an HTML comment. This information is used to associate tags, category, date and title of pages and posts. An example below:

tags: Node.js, JavaScript
category: Tools
title: Light-weight blog generator with Node.js and Markdown
date: 2014-08-28

This is an exhaustive list. Of course, new items can be added and extracted by blgn.

Post comments are handled by an external service, Disqus. Anyway, the integration is a simple JavaScript tag to add in the source. Spams are deleted from the service, we do not need to be worried about that.


A fact that no one can contest: less we do operations, faster is the rendering. This is one of what I am aiming with blgn. No server operations are required to output HTML like PHP, Python or Ruby but a Web server like Apache, Nginx, etc.


There are many good minifier tools on the Internet that I didn’t want to build my own but to stay focused on the blog generator system. In the list of used minifiers, there are: UglifyJS2, an effective minifier tool for JavaScript files that handles Source maps, ycssmin for CSS minifications (a fork of cssmin) and HTMLMinifier to minify HTML files that gives us a lot of options.

In addition, I wanted to build on-top of theses tools a minifier for IDs and Classes used in JavaScript files and CSS files. This IDs/Classes minifier targets the performance that I am looking for. That is a little improvement but it saves some bandwidth, especially if the CSS contains many rules. The goal of this minifier is to get something like:

<div class="a q D j K">
    <span id="e">text</span>


Many improvements need to be done. blgn has to reach a maturity to be suggested as a real alternative of CMS.

  • Improvements in templates: support conditional instruction, complex loop.
  • Make the implementation of a theme (templates) easier.
  • Make blgn a Node Package Module.
  • Build a standalone server for quick tests when developing.
  • Add a feature to deploy files on FTP.

To wrap things up, blgn needs to be comfortable to use for technical bloggers. If someone is interested to develop that open source project, feel free to make pull requests. 🙂