In order for Jekyll to serve up the pages you create you need to run its server component. The usual way to do this is by running the following at the command line;

jekyll serve

In Jekyll 2.5.x this will run the web server and a watcher by default. The watcher checks for changes that are being made on the fly and continues to serve.

The above command is run on the presumption that your source, destination and ports settings exist in the _config.yml file at the root of your site

This process will not run in the background. Not ideal if you either want to log off the terminal or edit the blog at the terminal with vi or nano or whatever.

So Jekyll provides a way to detach the Jekyll serve process from the terminal

jekyll serve --detach

On the surface this works great, but output from Jekyll is displayed when viewing files within a terminal editor, such as vi or nano.

When I first started out hacking this blog together I performed most tasks at the terminal and so needed to be able to run Jekyll in the background without distraction. I tried the following;

jekyll serve --detach & 

Even though the process went to the background, I as still seeing output coming from the Jekyll serve process. This was pretty frustrating when editing files with vi.

So the next step was to set up some redirection thus getting rid of the distracting Jekyll process output.

Here is the command line including redirection;

jekyll serve > /dev/null 2>&1 &

2> redirects stderr to an (unspecified) file, appending &1 redirects stderr to stdout with the & sending the process into the background.

This command also allows me to disconnect from the session and keep the Jekyll server/watcher running.

It’s a shame that there is no way (that I can find) to run Jekyll, detached without the output.

There are other ways to skin this cat, you could install ‘screen’ and run the process in that, but its more faffy.

Maybe Ruby offers a way to run processes in the background like ‘forever’ does for Node?

Answers on a postcard…