Test Jekyll Generated GitHub Pages Locally Using Docker

Github Pages & Jekyll

You can create a website directly from a GitHub repository. GitHub Pages have a built in support for a static site generator, Jekyll.

Test Locally with Docker

Testing generated pages locally before deploying to GitHub is possible, but installation of Jekyll is not extremely simple.

  1. Install Ruby
  2. Install RubyGems
  3. Install GCC and Make
  4. Install Jekyll
  5. Confgure …

Easier way is to use Docker image with a correct configuration: starefossen/github-pages

Start image by going to your github.io-directory with Jekyll generated site and mount your directory in a volume under /usr/src/app.

# Linux / macOS
$ docker run --rm -v "$PWD":/usr/src/app -p 4000:4000 starefossen/github-pages

# Windows
$ docker run --rm -v %cd%:/usr/src/app -p 4000:4000 starefossen/github-pages

Go to http://localhost:4000 and see your page. All changes you make to the files are refreshed automatically.

Written on June 20, 2021