Using Jekyll to build a simple static site

In my last post I covered installing Jekyll (and bundler) and now I’m finally ready to start build a small static site following the instructions here.

In my home directory, I generate a new project with jekyll new testsite.

This scaffolds the project files:

404.html

about.markdown

_config.yml

Gemfile

Gemfile.lock

index.markdown

_posts (directory)

_posts/2025-01-05-welcome-to-jekyll.markdown

Now we can cd testsite and serve the pages with bundle exec jekyll serve.

Unfortunately for me, that gives a two errors. Jekyll’s documentation says to install webbrick.

So within the testsite dir, run bundle add webrick and try serving again.

Still didn’t work. Let’s take a closer look at the errors:

  1. warning: logger was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0. You can add logger to your Gemfile or gemspec to silence this warning
  2. warning: csv was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0. You can add csv to your Gemfile or gemspec to silence this warning.

So we need to add those dependencies manually using bundler. This is simple: bundle add logger csv. Serve again.

Another error!

  1. warning: base64 was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0.
    You can add base64 to your Gemfile or gemspec to silence this warning.

So we bundle add base64 and serve again.

This time, it works! Kind of.

After a litany of sass deprecation notices, Jekyll delivers the success message along with the server location to load.

Unfortunately, this doesn’t work across my local network even when targeting the correct host IP/Port. This is because the server is specifically listening to the default loopback address of 127.0.0.1:4000, which is only accessible to itself.

So, instead, we need to serve the files using this:

bundle exec jekyll serve --host 0.0.0.0

The 0.0.0.0 catches the loopback but also the network address.

So now, I can load the site locally across the network!

However, let’s set one more improvement by passing --livereload. This will listen for changes on the filesystem and deliver updates to a specific port:

bundle exec jekyll serve --host 0.0.0.0 --livereload

My livereload listening port is :35729 though yours might be different. Making changes to any of the loaded resources should trigger a page refresh, which it does! Another bonus is that this now allows for my local DNS server to pass requests through using my defined scheme, so I can refer to the machine by its hostname on my domain!

Now that we can quickly test changes, let’s move on to more complexity in Jekyll.

Leave a Reply