Create an empty Jekyll site step by step

Posted by Bruce Liu on August 18, 2024

🏷️ Tags: Jekyll , Github , Ruby , Bundler , linux

development environment

  • Linux

  • git

    sudo apt install git
    git -v
    
  • Ruby (and RubyGems)

    sudo apt install ruby
    ruby -v
    gem -v
    

    Maybe gem source have to be changed.

    gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
    gem sources -l
    
  • Bundler

    gem install bundler
    bundle -v
    

    Maybe bundler source have to be changed as well.

    bundle config mirror.https://rubygems.org https://gems.ruby-china.com
    bundle config
    bundle config mirror.https://rubygems.org
    
  • Jekyll

    gem install jekyll
    jekyll -v
    

Start a new Jekyll project

  jekyll new <YOUR PROJECT NAME> --blank

Set up git

  cd <YOUR PROJECT NAME>
  git init

Maybe rename the branch.

git branch -m <OLD BRANCH NAME> <NEW BRANCH NAME>

Create a file named .gitignore and paste the following in it:

  _site/
  .sass-cache/
  .jekyll-cache/
  .jekyll-metadata
  node_modules

Install Ruby gems

Create a Gemfile which is a list of gems used by your site. Add it to the root directory with the following content:

  source 'https://rubygems.org'

  gem 'jekyll'
  gem 'webrick'

Now install those gems by Bundler.

bundle

Build the Jekyll site

bundle exec jekyll serve

Open https://localhost:4000 in your browser. If you see something like this.

readytogo

Publish to Github (optional)

Add files to the staging area and commit your changes.

  git add .
  git commit -m 'Your commit message'

Create a Github repository.

  • Go to GitHub.com and sign in to your account.

  • Click on the “+” button in the top right corner and select “New repository.”

  • Give your repository a name and description.

  • Choose whether you want the repository to be public or private.

  • Click “Create repository.”

Connect the local repository to Github.

git remote add origin https://github.com/<your_username>/<your_repository_name>.git

Push your local changes to Github.

git push origin main

You’r made it.

You can find the takeaway repository from https://github.com/longavailable/empty-jekyll-site.


Share on:

« PREVIOUS: Sites worth sharing
NEXT: The detailed steps of installing Home Assistant Operating System on Ubuntu »