Github pages is a great way to host a Jekyll website. However by default github pages, runs an old version of Jekyll (3.9.0). I want to understand why, and remove this limitation.
The approach I’m taking is to setup a new ‘site’ on github to trial this with. Starting with a new site as the template, and referencing this guide.
Presumes you have Ruby / chruby setup.
Create a new github repository
Clone that repository
Copy the blank project we just created to a local directory.
% cd ~/playground/
I use GitKraken, but feel free to use any other git tool, such as GitHub Desktop.
Confirm ruby version we want
A good reference for the current release is:
endoflife.date
Choose a version from here.
Today this is 3.2.2
Use chruby to confirm current version available and enabled.
% chruby 3.2.2
% chruby
ruby-3.0.6
ruby-3.1.4
* ruby-3.2.2
% ruby -v
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin23]
Create a new Jekyll project
In the same directory we just enabled ruby 3.2.2
% gem install bundler jekyll
Successfully installed bundler-2.4.22
Successfully installed jekyll-4.3.2
2 gems installed
% jekyll new .
Running bundle install in /Users/tom/playground/cobalt...
Bundler: Fetching gem metadata from https://rubygems.org/............
Bundler: Resolving dependencies...
Bundler: Bundle complete! 7 Gemfile dependencies, 33 gems now installed.
Bundler: Use `bundle info [gemname]` to see where a bundled gem is installed.
New jekyll site installed in /Users/tom/playground/cobalt.
Ruby version file
By default chruby will keep the default enabled version of Ruby active between
directories.
However we can force chruby to activate a particular version with a
“.ruby-version” file.
Which the auto-switching script looks for.
% echo 3.2.2 >> .ruby-version
To test it’s working as expected
% cd ~
% chruby 3.1.4
% cd -
% ruby -v
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin23]
Create starter script from GitHub Actions
We should now have a jekyll site that is available locally using an updated version of Jekyll. Now we need to tell github pages how to deal with this (instead of using the default Jekyll configuration).
https://github.com/[profile]/[repo]/actions/new
so in my case:
https://github.com/rakuna/cobalt/actions/new
Then search for Jekyll.
Once found commit the jekyll.yml to the repository.
After some tweaking I ended up with the following
Actions script.
Configure repo to run github pages
Once all the actions are setup, we need to ensure github knows to look at the gh-pages branch for the website. https://github.com/rakuna/cobalt/settings/pages
Update Gemfile.lock
Lastly
% bundle lock --add-platform x86_64-darwin-20