A Simple Static Site Generator
Built using Node.js, Markdown, and Handlebars
While picking a static site generator from the ever-expanding list of possibilities certainly makes it easy to start building a small website, it's not nearly as much fun as creating your own generator. Tools like npm and node.js make doing the hard and boring parts (like parsing markdown) as simple as installing a package, and not having to wrestle with configuring someone else's idea of how a site should built is well worth the effort of assembling these pieces into something that does exactly what's needed.
This site is built from articles written in Markdown, using a bit of YAML for extra information like dates and tags. Each article is inserted into a Handlebars template to become it's own HTML page and also listed on an index page. I use rsync to deploy the site to my server. I also run a local development server to preview changes before deployment, which I'll write about later.
The build process is fairly simple:
- Create a list of all the articles
- Sort by date
- Process the list
- Parse YAML front-matter and render Markdown to HTML
- Write article to file via the Handlebars template
- Add article data to list for the index page
- Render the index page
I've published a simple version on github as static-generator-starter-kit. Hopefully this is enough to encourage someone to start building their own static generator!