Getting started
Requirements
- Ruby 4.0 or newer
- ImageMagick headers, for the
rmagickgem that Klenod’s image plugin uses - OpenSSL headers, for the
opensslgem
On Debian or Ubuntu the headers are in libmagickwand-dev and libssl-dev.
Install
Make a directory for the site with a Gemfile:
source "https://rubygems.org"
gem "rista"
Then run bundle install.
Configure
klenod.config.rb sits next to the Gemfile. It names the source directory
and turns on Rista’s plugins:
require "rista"
source_dir "src"
plugins Rista.plugins
Write a layout and a page
src/routes/+layout.haml is the HTML document:
%html{ lang: "en" }
%head
%meta{ charset: "utf-8" }
%title My site
= $stylesheets.map do |href|
%link{ rel: "stylesheet", href: href }
= $scripts.map do |src|
%script{ type: "module", src: src }
%body
= $children
src/routes/+page.haml is the front page:
%h1 Hello
%p This page is a static file.
Serve and build
bundle exec rista serve # http://localhost:4000, reloads on change
bundle exec rista build # writes the site to out/
bundle exec rista build -o dist # or to another directory
serve takes --host and --port. build empties the output directory
before it writes, so do not point it at a directory with other files in it.
build fails when a page links to a path the site does not have, and lists
each broken link with the page it is on:
Broken links:
/about links to /about/team
It checks href and src values that lead into the site. Links to other
hosts are not checked, and neither is the #fragment of a link. For a site
that links to paths something else serves, --skip-link-check turns the
check off.
After a build, out/index.html is the front page, and out/assets/ holds the
hashed stylesheets, scripts and images.
Files with a fixed name
A public/ directory next to klenod.config.rb is copied into the output as
it is. Use it for files that need a fixed name, such as favicon.ico,
robots.txt or CNAME.