Quick Tips for Deploying a Jekyll Blog with Git

I built this blog using Jekyll and I wanted to share a few notes about how I went about deploying it from development. Overall the process was pretty straightforward, but there were a few hiccups caused by what I felt was incomplete documentation elsewhere.

Before I get into that it’s worth noting the tools I’ve used to build this site. The following notes might not be applicable to you if you’re not running something similar.

These notes are also based on the instructions from this article on Digital Ocean about deploying a Jekyll blog with Git, as well as the official Jekyll docs. I would definitely read those two articles carefully as the following notes are more complimentary to these methods, rather than an alternative.

Preparing the VPS

Make sure Git is properly installed. On an Ubuntu server this can be done with the command, $ apt-get install git-core, but on a fresh server I found this didn’t initially work for me. After doing some research I discovered I needed to update my entire system with $ sudo apt-get update before I could successfully run the install command.

If you created a new user on your server (you’re not still running on root, right?), you also need to make sure that user has read/write access to the /var/www directory (or wherever you’ve setup Apache to look for your blog content). I initially forgot to do this, which lead to permissions errors when trying to deploy with git. Correct this with the following command, $ chown -R username:username /var/www. Remember to change username to your own.

When it comes time to deploy you’ll run into problems if you set your server’s port to anything other than 22. Git will complain that you don’t have access to the remote repository. To fix this you need to use SSH in your $ git remote add ... statement and include the port number right after your IP Address. Here’s an example (make sure to include your own credentials): $ git remote add deploy ssh://user@ip.add.ress:1234/home/user/repos/blog.git

That’s it! Now you can locally run $ git push origin master to see your new posts pushed straight to the server.