Running Jekyll in Windows
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
- 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.
-
Clone the jekyll-vagrant repository
git clone https://github.com/jsturtevant/jekyll-vagrant.git
- Open command prompt to location of the
vagrantfile
in the new cloned repository and runvagrant up
- Jekyll and all it’s dependencies are installed!
Existing Jekyll Projects
- Copy the projects folder to the folder that contains the
vagrantfile
. - Login to the VM using
vagrant ssh
New Jekyll Projects
- Open a command prompt to location of the
vagrantfile
and runvagrant ssh
- Once in the VM prompt
cd /vagrant
- Create a new site with
jekyll new <sitename>
Start the Site
- In the VM prompt
cd /vagrant/<YourProjectFolder>
- Start the Jekyll server
jekyll serve --force_polling
(force polling is required with vagrant because of share) - On your host machine you can open any browser and navigate to
localhost:4000
- 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