Jekyll Github-pages locally in Ubuntu 22.04

Written on December 30, 2022; 1 minutes to read

I’m an enthusiastic admirer of Jekyll, which I use for all my static websites and this blog. The official GitHub documentation doesn’t help much as a guide to running Jekyll on my local machine. Here is how to run it in Ubuntu 22.04.

  1. Install Ruby.
    sudo apt install ruby-full
    
  2. Configure gems to ne stored in user home folder. For bash use .bashrc (for zsh, we would use .zshrc)
    echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc
    echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc
    echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc
    source ~/.bashrc
    
  3. Install Bundler
    gem install bundler
    
  4. You need to have a Gemfile in your website root folder to continue, here is mine as an example.
    source "https://rubygems.org"
    git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
    gem "github-pages"
    gem "jekyll"
    gem "jekyll-theme-architect"
    gem "webrick", "~> 1.7"
    
  5. Install dependencies.
    bundle install
    
  6. Run the server.
    bundle exec jekyll serve