Running Jekyll in Windows

I have an updated post using Docker to run Jekyll in Windows. The method described below is still valid but you know have more choices.

Setting up Jekyll for Windows is painful. To set it up you need to follow a multiple step setup process and cross your fingers. Julian Thilo has done a great job outlining all the steps and pitfalls on his Run Jekyll on Windows site. This is how I initially setup Jekyll but the trouble with this process is it takes several steps and potentially requires a bit of debugging to figure out.

I recently switch development machines, which meant I needed to setup Jekyll again and didn’t want to repeat the error prone process. At the same time I happened to learn how use Vagrant at the user group I organize.

Combining the two ideas I created a Vagrant Configuration for Jekyll. Now when I switch machines I have the same automated setup. I can be up and running in a few minutes and it is the same environment that is used for GitHub Pages.

Setup

  1. Make sure Vagrant and your favorite virtual machine are installed. I use Virtual Box and when setting up a new machine I already have these dependencies installed using Chocolately and BoxStarter.
  2. Clone the jekyll-vagrant repository

    git clone https://github.com/jsturtevant/jekyll-vagrant.git

  3. Open command prompt to location of the vagrantfile in the new cloned repository and run vagrant up
  4. Jekyll and all it’s dependencies are installed!

Existing Jekyll Projects

  1. Copy the projects folder to the folder that contains the vagrantfile.
  2. Login to the VM using vagrant ssh

New Jekyll Projects

  1. Open a command prompt to location of the vagrantfile and run vagrant ssh
  2. Once in the VM prompt cd /vagrant
  3. Create a new site with jekyll new <sitename>

Start the Site

  1. In the VM prompt cd /vagrant/<YourProjectFolder>
  2. Start the Jekyll server jekyll serve --force_polling (force polling is required with vagrant because of share)
  3. On your host machine you can open any browser and navigate to localhost:4000
  4. Work on you project on your host machine and see updates as they happen on localhost:4000!

Conclusion

Jekyll is a fun blogging platform but the support for Windows is limited. There are ways to install Jekyll directly on the host machine but they are tedious and error prone. By leveraging Vagrant we can have a fast, repeatable Jekyll setup that is in sync with GitHub Pages environment.

Comments

comments powered by Disqus