Deploy Jekyll with Capistrano
If you’re using Jekyll to generate your static website, you may want to deploy it as simple and fast, as Jekyll works. For this case, Ruby ecosystem has remote server automation and deployment tool that called Capistrano .
First of all, you need to create Gemfile in your Jekyll project and add this lines:
source 'https://rubygems.org' gem 'capistrano', '~> 3.4.0'
Then execute:
bundle install && bundle exec cap install
This creates configuration files, that you can change with your parameters. Make sure that you set up production configuration with your server data (/config/deploy/production.rb):
role :app, %w{user@server} role :web, %w{user@server}
After configuration you can deploy your project with one simple command:
bundle exec cap production deploy
This command deploys source to /var/www/websitename, but it does not
generate website. To execute jekyll build
command you need to install
Ruby using rbenv or
RVM first.
Next you should add Capistrano plugin for rbenv in Gemfile:
gem 'capistrano-rbenv', '~> 2.0'
Then execute
bundle exec
And add this line to Capfile:
require 'capistrano/rbenv'
Install Jekyll gem on server and add it to rbenv binaries list in config/deploy.rb:
set :rbenv_map_bins, %w{rake gem bundle ruby jekyll}
Now you can use my
capistrano-jekyll gem to
execute jekyll build
command every time when you deploy your website’s
changes:
# Gemfile gem 'capistrano-jekyll'
$ bundle install && bundle exec cap production deploy