The following information will help you get your Windows based PC set up to work with GitHub Pages using Ruby and Jekyll within the WSL (Windows Subsystem for Linux) environment. It will allow you to work with your files directly and run jekyll serve to test locally.

This setup assumes you have installed WSL2 using Ubuntu (which includes Git by default) for your version of Linux.

Setup Git Global Variables

First and foremost, you’ll want to configure a couple of Git settings. These settings are how your Git commits and changes will be tied to you.

Set Your Name & Email

git config --global user.name "Your Name"
git config --global user.email "your@email.tld"

Install Ruby

Jekyll is built using Ruby and as such you will be using it to test and build your GitHub Pages website. You’ll start by installing a Ruby Environment Manager, in this case rbenv, which allows you to set and use a specific version of Ruby. Because GitHub Pages builds with Jekyll v3.9.0, the current max version of Ruby we can install is v2.7.5 which supported by said version of Jekyll.

Install Ruby Environment Manager

sudo apt install rbenv

Add to PATH

echo 'eval "$(rbenv init -)"' >> ~/.bashrc

Install renv Ruby Build

mkdir -p "$(rbenv root)"/plugins
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

Run rbenv-doctor To Verify Install

curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash
You should see something like this if it was successful:
Checking for 'rbenv' in PATH: /usr/local/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking 'rbenv install' support: /usr/local/bin/rbenv-install
Counting installed Ruby versions: none
  There aren't any Ruby versions installed under '~/.rbenv/versions'.
  You can install Ruby versions like so: rbenv install 2.2.4
Checking RubyGems settings: OK
Auditing installed plugins: OK

Install Ruby

rbenv install 2.7.5

Set Local Ruby Version

rbenv local 2.7.5

This will tell rbenv what version of Ruby to use for this project. At this point you should be able to run ruby -v to check your Ruby install. It should return something along the lines of ruby 2.7.5. If you see that, and the version matches the version you just installed, you’re good to go.

Install Bundler

Finally, you will want to install Bundler. This will allow you to safely run Ruby gems on your system without and elevated (sudo) prompt.

gem install bundler