Jekyll on Win10
This blog lives on GitHub Pages, and my personal computer is running Windows 10. This is a lot like owning a cat and a dog. With enough time and effort, they’ll begrudgingly tolerate each other, and not much else.
I previously covered setting up my blog: Personalizing GitHub Pages.
Back in the dark ages–so, like, three months ago–I used to commit and push every single tweak to see how Jekyll/GHP/my theme behaved. You can look through this blog’s commit history for multiple fun sessions of 5-6 straight commits trying to wrestle with CSS.
That process is lame, so you have
two options only one option:
- Be like me, and follow @FooBartn’s “Install Jekyll on Win10 (The Awesome Way)”
- Jekyll on Ruby on Bash on Ubuntu on Windows
- Follow the official Jekyll on Windows walkthrough
- Update Dec 2017: Which now recommends doing it The Awesome Way™
I’m posting this because I want a public record of the process I used, and so I have a quick reference of how to run Jekyll again when I forget next time :)
What To Do:
Again, this install is just a copy from @FooBartn’s post. It worked for me in March 2017. (EDIT: December 2017 on Win10 1709.)
# Enable Windows Dev Mode $DevModeKey = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\AppModelUnlock\' Set-ItemProperty -Path $DevModeKey -Name 'AllowDevelopmentWithoutDevLicense' -Value 1 -Type DWord Set-ItemProperty -Path $DevModeKey -Name 'AllowAllTrustedApps' -Value 1 -Type DWord # Open the App Wizard & appwiz.cpl
- Select Turn Windows features on or off (Left Sidebar)
- Scroll down and check the box labeled “Windows Subsystem for Linux Beta”
- Allow your computer to restart
yto continue, then follow the instructions
EDIT Dec 2017: Windows Subsystem for Linux is now out of beta. What I found, when going through this process again on Win10 1709, is that it no longer chooses a distro for you.
Instead, you are pointed at aka.ms/wslstore, which lets you choose to install Ubuntu/openSUSE/SLES/Fedora.
For this walkthrough, install Ubuntu from the Windows Store.
Ok, from the bash prompt after the Ubuntu install:
# Update all packages sudo apt-get update && sudo apt-get upgrade # Install git and essentials sudo apt-get install build-essential git-core curl # Prerequisites: sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev # GPG key gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 # Grab RVM via curl curl -sSL https://get.rvm.io | bash -s stable # Load RVM on login with .bashrc echo " " >> ~/.bashrc echo "# This loads RVM into a shell session." >> ~/.bashrc echo ". ~/.rvm/scripts/rvm" >> ~/.bashrc # Re-source .bashrc source ~/.bashrc # Install Ruby via RVM rvm install 2.3.1 # Tell RVM to use 2.3.1 by default. Use ruby -v to verify. rvm use 2.3.1 --default ruby -v # After that is done you can install Bundler gem install bundler # And finally: Install Jekyll! gem install jekyll
On Each Run
Search for “bash” in the Windows start menu. You should get “Bash on Ubuntu on Windows” as your top result. Run it.
# You'll probably be told "X packages can be updated." upon launch # Update all packages sudo apt-get update && sudo apt-get upgrade # (will prompt for the password you created during initial setup) # Go to the directory you cloned your blog repo to # Tab completion works, but case-sensitivity matters cd /mnt/c/Github/brianbunke.github.io/ # Run jekyll, building and watching the current directory: jekyll serve -w --force_polling
Then, as referenced in the Bash window, you can hit
http://127.0.0.1:4000 in your browser to view the local version of your site.
If you want to make any tweaks while Jekyll is running, it’s also watching. You’ll see a “Regenerating:” line in the Bash window after each save, after which you can simply refresh your browser.
Note that you should be able to just run
jekyll serve, but there is (was?) a bug. No idea if this is available to the general public, but I’m still doing it the long way as of May 2017.
Local previews make the writing/editing process far more tolerable, and removed the only real pain point I was feeling after migrating to GitHub Pages. But of course, don’t take my word for it, it’s your turn to try it out!