If you want to test locally how your blog or project page will look like when published to Github Pages, you can run Jekyll inside a docker container.

To run the Jekyll docker container you need to run the following command from the root of your Jekyll site.

docker run --rm --label=jekyll --volume=$(pwd):/srv/jekyll \
  -it -p 127.0.0.1:4000:4000 jekyll/jekyll:stable

If you are using direnv, you can create a executable script, add it to your PATH environment variable and use it to start the containe.

Create a file under the bin folder in the root folder of your project and create a file called jekyll inside of it. The content of the file is as follows:

#!/bin/zsh

docker run --rm --label=jekyll --volume=$(pwd):/srv/jekyll \
  -it -p 127.0.0.1:4000:4000 jekyll/jekyll:stable

Note: Don’t forget to make the file executable.

Then edit the .envrc file by adding the following entry into it:

PATH_add bin

To run the container, you will just need to run jekyll from the root folder of your project.

jekyll