When building a website with Jekyll, you might want the site to automatically rebuild when you make a change. You can do that with the jekyll build --watch command. Then of course you’ll want to serve the website so you can preview it in the browser. For that there’s the jekyll serve command.

Running both commands at the same time requires opening separate terminal tabs. This can be a little bit frustrating. Especially when you start adding more features to your site. For example, if you want to use compass to compile SASS, you’ll need to open a 3rd tab to run compass watch.

Doing this over and over again every time you want to edit your site can become a little tedious. Each time you’ll have to open at least two tabs, and remember which commands to run to get things started. And, if you haven’t worked on the site for a while, you might not remember all the components you’re using.

Fortunately there’s an awesome gem called Foreman that can help you out with this. Here’s how to get it up and running with Jekyll.

First, install the gem:

$ gem install foreman

Then, create a new file called Procfile in the root of your Jekyll project folder, and add the tasks you want running in parallel. Using the three tasks mentioned above as an example, your Procfile might look something like this:

build: jekyll build --watch
server: jekyll serve
compass: compass watch

To start all the processes in parallel, just run:

$ foreman start

Now you can manage and monitor all the processes in just one tab. Pressing CTRL+C will automatically send the KILL signal to every task for you.

comments powered by Disqus