Hosting a VPS-based Jekyll Site

As I was trying to set up this blog, I ran into some issues regarding running Jekyll, a static site builder, and wanted to write a short post helping anyone attempting the same configuration that I was shooting for.

I began with my digital ocean hosted VPS (which, for students using the github student dev pack, offers $60 of hosting credit) with Apache2, as I haven’t been exposed to much nginx.

My goal was to get a modifiable jekyll repo on my local machine that I could update posts/blog with. I wanted to work on my local machine, in case I didn’t have internet/connection to my server, and then push changes to my VPS and github.

So we need three things:

  1. A local git repo
  2. A github repo
  3. A remote repo on our VPS

We can begin by installing jekyll and it’s dependencies on both our remote and local machine:

$ sudo apt-get install ruby ruby-all-dev git-core build-essential
$ sudo gem install jekyll

Let’s say we wanted to use someone’s open source jekyll theme. I found mine from here, as I did not want the basic jekyll layout. Shoutout to niklasbuschmann for making the awesome theme! What we do now is fork the theme on github, then clone the fork.

On our local machine:

$ git clone https://github.com/sid-devic/contrast

cd into the cloned directory. Then pop:

$ jekyll serve

to check if your jekyll installed correctly. If it did, you should be able to navigate to in your browser and see the theme you just cloned, basic and unmodified.

If you ran into a jekyll dependency error (I did), just install whatever jekyll packages you were missing:

$ sudo gem install jekyll-packagename

Now that we have the theme working on our local machine, it’s time to create a copy on our remote machine.

$ sudo 

We make a new directory, cd into it, then initialize a “bare” git repo. We do this because we want the repo on our remote machine to be in sync with the one on our local machine. Next,

comments powered by Disqus