Jekyll

Can I deploy Jekyll to my Hatchbox server?

Of course! While we don't provide official support for this, it's really easy.

  1. Add a deploy script to your Jekyll repo.

  2. Create an NGINX server config for your Jekyll site.

  3. Run the deploy script anytime you want to deploy your site.

1. Add the deploy script to your repo

Paste the following into your Jekyll repo and commit it to git.

Change the IP_ADDRESS to the IP address of your server and change example.com to the domain of your app. This will create a folder called example.com where your Jekyll site will live on the server. Using the domain will make it easy to find

jekyll build
rsync -azvh _site/* [email protected]_ADDRESS:/home/deploy/example.com

2. Create your NGINX config

You can paste the following config into /etc/nginx/sites-enabled/jekyll to setup NGINX. Make sure to change your server_name and root folder to match the domain and folder you want to deploy to.

/etc/nginx/sites-enabled/jekyll
server {
listen 80;
listen [::]:80;
server_name example.com;
root /home/deploy/example.com;
index index.html index.htm;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri.html $uri/ $uri /index.html;
}
}

After you've created this file, run sudo service nginx reload to restart NGINX.

3. Run the deploy script to deploy

Anytime you want to deploy, cd into your Jekyll app, and run ./deploy.sh which will trigger a jekyll build and rsync all the files up to the server.