Getting started with Jekyll
Jekyll does what you tell it to do â no more, no less. It doesnât try to outsmart users by making bold assumptions, nor does it burden them with needless complexity and configuration. Put simply, Jekyll gets out of your way and allows you to concentrate on what truly matters: your content.
Jekyll is a simple, blog-aware, static website generator. Itâs like making sausages: you put in Markdown files and some HTML/CSS formatting, and it outputs a nice website that you can deploy anywhere. Jekyll is mostly known for two reasons: it makes starting a website very easy, and it has embedded blog support.
The reasons that makes it so easy to get started with Jekyll is that it works out-of-the-box without extra configuration steps, and there are plenty of styles available online, so you can skip designing the website for a while and go straight to writing content; this is very helpful particularly if you donât know what your website is going to be about or what you want it to look from the start, so when youâre done posting some content youâll have a clearer picture about how to present that content.
As I said earlier, it only facilitates static website generation and that is only if youâre mostly worried about getting content out instead of designing each page individually; it is not typically the best framework for websites where each page has a different and intricate design, or if you want some sort of backend, in which case youâre gonna have to look for something more sophisticated. However, Jekyll is perfectly fine for personal and company portfolios, blogs, etc. This website is 100% made using Jekyll.
Its popularity also stems from the fact it was adopted by Github as the engine for its widely known Github Pages feature. Truly, using Jekyll and Github to launch your static website is the perfect combo for the shortest setup period possible, as well as the best content publishing and version tracking experience possible.
When youâre deploying your website locally, Jekyll automatically regenerates your website when it detects youâve edited a file.
I will be assuming youâre using the same Jekyll setup as I am: version tracking using Git, repository hosting with GitHub and deploying your website with GitHub Pages. The process is otherwise similar if youâre using other tools/platforms.
Installing
To install, just follow the guide provided in Jekyll docs. Under Windows and Linux, it basically requires you to install Ruby, and then install the two required gems jekyll
and bundler
. On Linux you need some extra packages, but Iâd even say installing is much more straightforward on Linux than on Windows.
Getting started
To get started, just follow this quickstart; it guides you through creating a very simple website. To make it available using GitHub Pages, you have to:
- Create a new GitHub repository.
- Enable GitHub Pages for your repository, and make GitHub Pages point to your master/main branch.
- Add a
.gitignore
file with the following contents:
_site
.sass-cache
.jekyll-cache
.jekyll-metadata
vendor
Gemfile
Gemfile.lock
config
- Stage your website, commit and push to the remote repository.
On step 3 youâre basically ignoring the generated website (_site
), caches and the Gemfile
; GitHub Pages will generate all of that for you from scratch.
Deploying an existing repository
To deploy an existing repository locally (which you might be interested in should you use more than one computer), just clone the repo, then run bundle init
, open the Gemfile
that was just created, and paste
source 'https://rubygems.org'
gem 'github-pages'
This is basically what GitHub Pages does for you when deploying your website.
Then run:
bundle install
bundle exec jekyll serve
If youâre under Windows, you might want to follow the advice on Jekyllâs logs and add Windows Directory Monitor (WDM) to your Gemfile
, by simply pasting
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
This will make site regeneration smoother by better tracking the changes to your contents.
IMP: Since the beginning of 2021 there has been a minor issue with the Microsoft Windows Jekyll gem not working straight out-of-the-box. It shows the following error:
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve/servlet.rb:3:in `require': cannot load such file -- webrick (LoadError)
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve/servlet.rb:3:in `<top (required)>'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve.rb:184:in `require_relative'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve.rb:184:in `setup'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve.rb:102:in `process'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve.rb:93:in `block in start'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve.rb:93:in `each'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve.rb:93:in `start'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve.rb:75:in `block (2 levels) in init_with_program'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/exe/jekyll:15:in `<top (required)>'
from C:/Ruby30-x64/bin/jekyll:23:in `load'
from C:/Ruby30-x64/bin/jekyll:23:in `<main>'
To solve it just follow the workaround in the issue, it worked just fine for me: install WEBrick manually by running command bundle add webrick
.