This is how I created this GitHub user site with Jekyll on macOS.

Prerequisites

Instructions

Set up environment

  1. Install bundler and jekyll without root

    $ gem install --user-install bundler jekyll
    
  2. Check ruby version

    $ ruby -v
    ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]
    
  3. Add gems path to shell configuration

    # If your ruby version is not 2.6.X,
    # then you need to replace 2.6 with the first two digit of your ruby version
    $ echo 'export PATH="$HOME/.gem/ruby/2.6.0/bin:$PATH"' >> ~/.zshrc
    
  4. Clone <user>.github.io repository

    # Replace <user> with your username
    $ git clone https://github.com/<user>/<user>.github.io
    $ cd <user>.github.io
    

Create the site

  1. Create a new Jekyll site

    $  jekyll new --skip-bundle .
    
  2. Enable GitHub page in the site

    1. open Gemfile file

    2. add # to the beginning of the line starts with gem "jekyll"

    3. remove # from the line starts with # gem "github-pages"

    4. install the gem

      $ bundle config set --local path 'vendor/bundle'
      $ bundle install
      
  3. Testing the site locally with Jekyll

    1. build the site and make it available in local server

      $ bundle exec jekyll serve
      
    2. browser to http://localhost:4000

Publish the site

  1. commit the code to GitHub

    $ git add .
    $ git commit -m 'Initial GitHub pages site with Jekyll'
    $ git push
    

Your site should be available at https://<user>.github.io after a few minutes.

See also