After around 4 years of not updating my website, finally I've got some free time in our Nowruz holidays to make myself a gift, a new website!
I love static site generators, static sites are fast, there is no need to deal with administration panels, no need to databases, no risk of being hacked, and no bullshit. There are plenty of them out there, but I couldn't pick any. I'm a minimalist and I wanted something as simple as possible for my own needs. So I decided to write my own from scratch, using node.js of course.
The structure is really simple. There are 3 types of pages:
- Simple pages like about page.
- Blog posts like this page.
- And project pages.
I store them in separate folders: pages, posts, and projects. Also every page has its own folder, so related stuff like images can be stored in its own folder.
Pages can be written in markdown or html. Also each page has a json configuration which holds data like page title, publication date, and etc.
Then I needed a template engine. Templates should be plain html files without any special markup. So how to put data in them? I didn't say templates doesn't need logic but logics should be separated. Every template should have a logic script to inject data to the template. There are weld and plates, but for me jsdom was enough.
Also I needed a syntax highlighter. I used highlight.js with solarized theme. My generator automatically adds this script to every page containing code blocks.
And one more thing, posts should have an RSS feed. No problem, node's rss module is great and pretty easy to use.
And finally disqus for the comments.
That's it. Thanks to Open Source, I wrote it in less than 200 lines.
Then I started to design a theme for it. A simple, light, clean, and responsive design using HTML5 and CSS3 features.
Well, I'm done. This is exactly what I wanted and I'm really satisfied.