This guide will set you up with everything you need to create a brand new blog with Jekyll and GitHub Pages. All you’ll need is a GitHub account and a machine running Ubuntu or Debian.
Installing Ruby
To get started install Ruby on Ubuntu or Debian, it’s included by default within Ubuntu’s repositories. If you run into issues check out Ruby’s website, otherwise just use these two commands:
sudo apt update
sudo apt install ruby-full
You’ll also want to add these lines to your shell profile (e.g., .bashrc) so that you can access all the commands you’ll need:
export GEM_HOME="$HOME/gems"
export PATH="$HOME/gems/bin:$PATH"
Then load the new shell profile, the easiest way to do this is relaunch your terminal.
Installing Jekyll and creating the blog
We can now use Gem to install Jekyll using this command:
gem install jekyll bundler
Next, we can create the new blog using what we just installed:
jekyll new blog
Now, let’s make sure that everything runs okay! To do this we’ll start a simple testing server with:
bundle exec jekyll serve --livereload
💡 If you encounter: Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby'
You can likely fix this error simply by reinstalling the event machine:
gem uninstall eventmachine
gem install eventmachine --platform ruby
bundle exec jekyll serve --livereload
Publishing
Now that we have a fully functional blog we can publish it using GitHub pages. To do this we’ll use GitHub CLI to create a repository, the tool can be installed on Ubuntu and Debian (amd64) derived distributions like so:
curl -LO https://github.com/cli/cli/releases/download/v2.12.1/gh_2.12.1_linux_amd64.deb
sudo apt install ./gh_2.12.1_linux_amd64.deb
Now we’ll need to create a Git repository in our blog’s directory by running git init and create a commit with:
git add . && git commit -m "initial commit"
and we can create a repository with gh repo create. Now we can navigate to our repository’s settings on GitHub and enable GitHub pages.
Custom Domain
If you have a custom domain name you can create a CNAME record in your DNS that points to YOUR_USERNAME.github.io and type in your domain name in the “Custom domain” section of GitHub page’s settings.
Congratulations! You know have a fully function and public blog running! Thank you for checking it out! Happy publishing!
Leave a Reply