No bull** guide to install jekyll on ubuntu

Sometimes we gotta get our hands dirty

We’ll install a working Ruby using a version manager and then install Jekyll

A quick intro on Jekyll

Jekyll is a static site generator, that means you use it to generate static sites, it was written in Ruby and uses something called liquid templates to describe the web page.

What are static sites?

They’re sites where their content does not change over time. In simpler terms it means you make the site once and the site stay the same. The content does not change unless if you change it yourself modifying the site’s assets (HTML, CSS, JS) or using an external tool that does it for you.

That means static sites are well suited for blogs, landing pages etc…

Guess what this site is running on? (PS: It’s Jekyll)

Why did I write this

Installing Jekyll using their official Ubuntu guide does not work sadly, most likely because the ubuntu ruby package is outdated. So if you tried to install it using that way you’ll get errors, my friend.

Well then how can I install it?! Keep reading, amigo…

Important

If you previously tried to install Jekyll using the above mentioned broken guide, Make sure to do the following:

  • Uninstall Ruby:
    sudo apt-get remove ruby
    
  • Remove the environment variables placed inside your shell configuration file If your shell is BASH, you want to open the file, and remove the below lines:
    export GEM_HOME="$HOME/gems"
    export PATH="$HOME/gems/bin:$PATH"
    

Installing Jekyll

First things first, we need to install Ruby. Installing Ruby will give us 2 main things, the programming language itself (interpreter) and something called RubyGems which is a package manager for Ruby. Using RubyGems we will be able to install Jekyll.

We will install ruby using rbenv which is a popular ruby version manager. This will allow us to install multiple ruby versions and switch between them at ease.

Trust me, you will probably want multiple ruby versions because certain packages only work on certain versions.

Let’s get to it:

  • Clone rbenv into ~/.rbenv.
    git clone https://github.com/rbenv/rbenv.git ~/.rbenv
    
  • configure your shell to load rbenv, Execute one of the below commands depending on which shell you’re using! For bash:
    echo 'eval "$(~/.rbenv/bin/rbenv init - bash)"' >> ~/.bashrc
    

    For Zsh:

    `echo 'eval "$(~/.rbenv/bin/rbenv init - zsh)"' >> ~/.zshrc`
    

    For Fish shell:

    `echo 'status --is-interactive; and ~/.rbenv/bin/rbenv init - fish | source' >> ~/.config/fish/config.fish`
    
  • Close and reopen your shell

  • List the latest stable ruby versions
    rbenv install -l
    

    If the rbenv install command wasn’t found, you have to install ruby-build as a plugin: git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

  • Install the ruby version of your choice (As of writing this, the latest stable version is 3.2.1)
    rbenv install 3.2.1
    

You might get an error while installing, this is usually fixed by running sudo apt-get install libyaml-dev to install a dependency that ruby requires

Incase that fails too, see other dependencies that can be inspected

  • Set a Ruby version to finish installation and start using Ruby:
    rbenv global 3.2.1   # set the default Ruby version for this machine
    # or:
    rbenv local 3.2.1    # set the Ruby version for this directory
    

Like previously stated, there should no no previous ruby installation, if this is the case then rbenv should automatically set the system version as the newly installed version We can check that by running: rbenv version We should get back the same version we installed.

After that, we’re ready to install jekyll, baby!

gem install jekyll bundler