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

This guide assumes you have installed WSL2 using Ubuntu (which includes Git by default) as your Linux distribution.

Set Up Git Global Variables

First, you’ll want to configure a couple of Git settings. These settings ensure your Git commits and changes are 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, so you’ll need it to test and build your GitHub Pages website. Start by installing a Ruby Environment Manager, in this case rbenv, which allows you to set and use a specific version of Ruby. Since GitHub Pages builds with Jekyll v3.9.0, the maximum supported version of Ruby is v2.7.5.

Install Ruby Environment Manager

sudo apt install rbenv

Add rbenv to PATH

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

Install rbenv 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 Installation

curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash
If successful, you should see output similar to this:
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 command tells rbenv which version of Ruby to use for this project. At this point, you should be able to run ruby -v to check your Ruby installation. It should return something like ruby 2.7.5. If the version matches what you just installed, you’re good to go.

Install Bundler

Finally, you’ll want to install Bundler. Bundler allows you to safely run Ruby gems on your system without requiring elevated (sudo) permissions.

gem install bundler