Jekyll is one of the oldest static site generators and pioneered an entire category of tools to build websites. Instead of adding a cache and various performance improvements on top, it paved the way for websites that go beyond a few HTML files.
The previous example (still available on Github: runway-example-jekyll-docker) showed Runway’s extensibility — thanks to using a Dockerfile
. This updated and improved example shows how to use Jekyll without it.
The first step is to ensure you have Jekyll and bundler installed:
gem install bundler jekyll
Next, let’s create a new Jekyll site:
jekyll new my-website
cd my-website
git init
The following two dependencies need to be added to the your website’s Gemfile
, as they are required by Jekyll’s default theme:
bundle add sassc
bundle add sass-embedded
To in order to start Jekyll when the container starts, you have two options:
Rakefile
Procfile
.The Rakefile
(or rake
) is the Ruby native way to run tasks. Inside the Rakefile
you define CLI tasks that you expect your Ruby project to need.
If you want to use rake
to start Jekyll, ensure the dependency is added (bundle add rake
) and create a new file in your project’s root directory:
require 'bundler/setup'
require 'jekyll'
task :serve do
$stdout.sync = true
$stderr.sync = true
Jekyll::Commands::Serve.process({
'host' => '0.0.0.0',
'port' => ENV['PORT'] || '5000',
'verbose' => false,
'incremental' => false,
'livereload' => false,
'show_drafts' => false
})
end
task default: :serve
The Rakefile
defines a task called serve
and makes it the default. Inside serve
, we configure how Jekyll is started.
To test this locally:
bundle exec rake serve
The alternative is to run Jekyll with a Procfile
. We will not go into the details here, but your Procfile
doesn’t require additional dependencies and has to contain a cmd
process in order for it to work on Runway.
cmd: bundle exec jekyll serve \
--host 0.0.0.0 --port 5000 \
--disable-disk-cache --destination /tmp
The cmd
process defines how Jekyll is started — very similar to what you run locally.
Aside from the Rakefile
or the Procfile
, no other configuration is necessary to run Jekyll on Runway. The next steps are to stage your files (e.g. git add -A
) and to commit them (with git commit
).
Last but not last - create an application on Runway and deploy:
runway app create
runway app deploy
The entire source code for this example is available on in our Github organization in runway-example-jekyll and contains the Rakefile
and the Procfile
.