Jekyll and rbenv

How to setup Jekyll and Ruby

What is Jekyll

This site is running on Jekyll and I’m hosting this on Github. It transform MD files into websites, it is simple and fully customisable.

Install rbenv and Ruby

If you’re using MacOS, gem install bundler jekyll would show the following error:

ERROR: While executing gem … (Gem::FilePermissionError) You don’t have write permissions for the /Library/Ruby/Gems/2.3.0 directory.

ruby -v to check version, remember the version. This is because this Ruby files are needed for MacOS. So you need to install a separate Ruby environment with brew install ruby.

ruby -v again to check version, if it is the same, you have to restart (close and open) your Terminal.

Next, brew install rbenv to manage multiple Ruby versions. After it is done installing, run rbenv init and follow the instructions. Most likely it is requesting you to add eval "$(rbenv init -)" into ~/.bash_profile.

What I will do is to open .bash_profile file using nano ~/.bash_profile, and paste eval "$(rbenv init -)". Close and save the file.

Run curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash to check if everything is all right. If not follow the instructions shown in the Terminal. Sometimes restarting Terminal helps.

Install Ruby 2.7.1 with rbenv install 2.7.1, then followed by rbenv global 2.7.1.

ruby -v to check version. It should be showing the version you have just installed.

Install Jekyll

Now you can gem install bundler jekyll.

If you are using a Gemfile, run bundle update followed by bundle install.

Start Jekyll

To start Jekyll, change the directory to your Jekyll root folder by cd <path of working directory> And then simply jekyll serve to start your local server.

Alternatively, if you have you Gemfile in place, do bundle exec jekyll serve instead. And lastly, if you have written some posts in _drafts folder and would like these posts to be shown during development, run bundle exec jekyll serve --drafts.

Thanks for reading!