Installing Jekyll on WSL
- Install BASH on Ubuntu on Windows (WSL)
- Update BASH to latest LTS
- Install Jekyll
- Using Jekyll - Quickstart
- Install lighttpd to serve built jekyll site
- Serve the built _site
- Using oneDrive to host the Jekyll Site
This is what I had to do in order to get Jekyll running in a development environment. I found that there were too many issues running Jekyll on windows. Now that Microsoft supports Windows Subsystem for Linux, you can use this linux distribution as your development environment.
Install BASH on Ubuntu on Windows (WSL)
open command prompt as administrator
- Install Bash
lxrun /install /y
using /y will not prompt for user and will login as root
- UNinstalling Bash
lxrun /uninstall /full
this will remove the home dirs as well, just in case you want to clean things up
Update BASH to latest LTS
open BASH as Administrator
Run the following command to see if you need to update the Linux distribution. If you are running Windows 10 prior to 1703 (Creators Update), you will most likely need to do the update.
lsb_release -a
If the Release: version is lower than 16.04, you will need to do the update
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial
If you installed your bash instance with a user, remember to use
sudo
to run the following commands
apt-get update && apt-get upgrade -y
apt-get dist-upgrade
apt-get autoremove
do-release-upgrade -f DistUpgradeViewNonInteractive -d
If it gets stuck at a Y/N prompt.
PressCTRL + C
If your bash instance was installed with a user use
sudo -S dpkg --configure -a
dpkg --configure -a
apt-get update && apt-get upgrade -y
apt-get dist-upgrade
apt-get autoremove
If you get this error:
N: Ignoring file ‘50unattended-upgrades.ucf-dist’ in directory ‘/etc/apt/apt.conf.d/’ as it has an invalid filename extension
run:
rm /etc/apt/apt.conf.d/50unattended-upgrades.ucf-dist
Install Jekyll
Use the following to install ruby and build-essential. Build-Essential is a meta package that includes gcc and make and other tools required to install jekyll.
apt-get install ruby-full build-essential -y
gem install jekyll bundler
Using Jekyll - Quickstart
Create a new site
jekyll new siteName
Build the site
cd siteName
jekyll build
Your new static site is located in siteName/_site
Install lighttpd to serve built jekyll site
apt-get install lighttpd
/etc/init.d.lighttps start
Serve the built _site
You can copy your built _site to /var/www/html or make a symbolic link to you built _site dir
Copy the built _site dir
rm -rf /var/www/html/
cp siteName/_site/ /var/www/html -r
when you rebuild your site you will have to copy the site again. This tends to get very tedious when many build are being made.
Make a symbolic link to your _site dir
rm -rf /var/www/html/
ln -s /root/siteName/_site/ /var/www/html
chmod o+x /root
lighttpd by default will follow symbolic links. You need to change the permissions on /root or else you will get a 403 error
To access the built newSite from Windows use http://localhost
Using oneDrive to host the Jekyll Site
This is very useful if you use more than one computer to do your development work. As long as you can reach your oneDrive files from each computer. Make sure to do these steps at each of the systems you use for development.
Items like images or any other files can be added to the oneDrive folder so that it can be added to the built Jekyll site
First, create the siteName in the oneDrive folder
cd /mnt/c/Users/username/OneDrive
jekyll new siteName
Change back to your home dir using cd
Now make a symbolic link to the oneDrive site directory
ln -s /mnt/c/Users/username/OneDrive/siteName siteName
You can even make a symbolic link to your _site dir so that it points to /var/www/html using the above steps