Jekyll Snippets

Table of Contents

Some quick solutions when using Jekyll to generate static sites.

How to run Jekyll with Docker

Installing Jekyll and Ruby can be difficult on certain operating systems. In those cases it is helpful to instead run Jekyll as a Docker container. Here is an example how to build and serve the project located at /path/to/project with the docker container:

docker run --rm -it \
  --volume="/path/to/project:/srv/jekyll" \
  --env JEKYLL_ENV=production \
  -p 4000:4000 \
  jekyll/jekyll:4 jekyll serve

The specific image in this case is jekyll/jekyll:4. The various tags and version can be found on the jekyll/jekyll docker repository.

How to serve Jekyll on the local network

In order to serve your site on the local network you can run

jekyll serve -w --host=0.0.0.0

In order to figure out the IP address of the site on a Windows machine, you can use the command ipconfig in cmd, or ip a in Linux and search for the network you use currently. For example search in Wireless LAN adapter Wi-Fi for Ipv4 when you want to access the site on your phone or other machine from your WiFi network.

I found the solution on Stack Overflow

How to run multiple Jekyll sites on the local network

By default Jekyll serves the site on port 4000. In order to run multiple sites simultaneously, each site needs to be served at a different port. This can be done by setting the port flag

jekyll serve -w --port 3000

The port can be also specified in the _config.yml file, by adding the Local Server Port with the option port: 3000. Further options can be found in the documentation.

How to create Jekyll Blog Posts with Jupyter Notebooks

It is possible to create Jekyll blog posts with Jupyter notebooks by simply converting the notebook to markdown.

jupyter nbconvert jekyll-notebook.ipynb --to markdown

Further resources can be found in the article by Adam Johnson and in Jupyter Readthedocs.