This past weekend was a very productive one for me, because I’ve started to work on and released my book’s one-page website —rapidprototypingwithjs.com. I’ve used Wintersmith to learn something new and to ship fast. Wintersmith is a Node.js static site generator. It greatly impressed me with flexibility and ease of development. In addition I could stick to my favorite tools such as Markdown, Jade and Underscore.
Why Static Site Generators
Here is a good article on why using a static site generator is a good idea in general, An Introduction to Static Site Generators. It basically boils down to a few main things:
You can use template engine such as Jade. Jade uses whitespaces to structure nested elements and its syntax is similar to Ruby on Rail’s Haml markup.
I’ve copied markdown text from my book’s Introduction chapter and used it without any modifications. Wintersmith comes with marked parser by default. More on why Markdown is great in my old post, Markdown Goodness.
Due to the fact that any static web server will work well, there is no need for Heroku or Nodejitsu PaaS solutions, or even PHP/MySQL hosting.
There are no database calls, no server-side API calls, no CPU/RAM overhead.
Wintersmith allows for different plugins for contents and templates and you can even write you own plugin.
Getting Started with Wintersmith
There is a quick getting started guide on github.com/jnordberg/wintersmith.
To install Wintersmith globally, run NPM with -g and sudo:
$ sudo npm install wintersmith -g
Then run to use default blog template:
$ wintersmith new <path>
or for empty site:
$ wintersmith new <path> -template basic
or use a shortcut:
$ wintersmith new <path> -T basic
Similar to Ruby on Rails scaffolding Wintersmith will generate a basic skeleton with contents and templates folders. To preview a website, run these commands:
$ cd <path> $ wintersmith preview $ open http://localhost:8080
Most of the changes will be updates automatically in the preview mode except for the config.json file.
Reading blog posts is good, but watching video courses is even better because they are more engaging.
A lot of developers complained that there is a lack of affordable quality video material on Node. It's distracting to watch to YouTube videos and insane to pay $500 for a Node video course!
[End of sidenote]
Wintersmith generator has the following logic:
- looks for *.md files in contents folder,
- reads metadata such as template name,
- processes *.jade templates per metadate in *.md files.
When you’re done with your static site, just run:
$ wintersmith build
Other Static Site Generators
Here are some of the other Node.js static site generators:
More detailed overview of these static site generators is available in the post, Node Based Static Site Generators.
Microsoft MVP | Book and Course Author | Software Engineering Leader
To contact Azat, the main author of this blog, submit the contact form or schedule a call at clarity.fm/azat and we can go over your bugs, questions and career.