sajad torkamani

Clone Git repo on server

SSH into server and clone Git repo. For example:

git clone <repo-url> <clone-path>

Build static site on server

Install dependencies

bundle install

If you’re deploying on a low-powered machine, you might find that sassc takes a very long time to install. In that case, consider pinning sasscc to a lower version by adding gem 'sassc', '~> 2.1.0' to your Gemfile.

Build site

JEKYLL_ENV=production bundle exec jekyll build

Configure Nginx

Create and enable the following Nginx config:

server {
  listen 80;
  server_name <domain> www.<domain>;

  root <clone-path>/_site;
  index index.html;

  location / {
    try_files $uri $uri/ =404;
  }
}

Remember that the root path of Jekyll websites is _site so ensure this is reflected in your Nginx config.

See this post for more info on configuring Nginx.

Configure DNS

Make sure you have configured your domain’s DNS to point to your server’s IP address.

Deploy updates

Everytime you update your repo, you can SSH into server and run:

git pull
bundle install
JEKYLL_ENV=production bundle exec jekyll build

You might want to automate this with a tool like Capistrano.

Tagged: Misc