Lock Ruby Version for Jekyll Sites

These are the steps to lock the Ruby version for Jekyll static websites. especially when the hosting site uses a specific version of Ruby.

For my case, I have two Jekyll websites hosted with different hosting providers, and both use different versions of Ruby.

Lock to a Specific Version

For this, I used rbenv – the Ruby Version Manager.

To install, I ran this command: curl -fsSL https://rbenv.org/install.sh | bash.

rbenv can also be installed using Homebrew.

For one of my Jekyll sites, Ruby version 3.2.2 is required.

Navigate to the root directory of the Jekyll website project and run the command rbenv local 3.2.2, where “3.2.2” is the Ruby version.

rbenv will create a ` .ruby_version file with “3.2.2” in the file.

GitHub Pages Ruby Gem

For Jekyll sites hosted on Github pages, there is a Ruby gem called “github-pages – https://github.com/github/pages-gem.

“A simple Ruby Gem to bootstrap dependencies for setting up and maintaining a local Jekyll environment in sync with GitHub Pages.” – README.md, pages-gem (GitHub)

Add “github-pages” to the project’s Gemfile like so: gem "github-pages", group: :jekyll_plugins.

Then run bundle install to install the gem.

Conclusion

By locking your Ruby version and using the appropriate gems, you can ensure your Jekyll sites are compatible with your hosting provider and avoid unexpected issues. Following these steps will help maintain a stable and reliable deployment environment for your static websites.

Share this:

Comments