Rista

Site layout

A site is a directory with a config file, a source directory and an optional public/ directory:

Gemfile
klenod.config.rb
public/                          copied as it is
src/
  site.rb                        site metadata
  posts.rb                       a module that pages import
  components/                    Haml components
  routes/
    +layout.haml                 the HTML document
    +page.haml                   /
    +not-found.haml              404.html
    blog/+page.haml              /blog
    blog/_posts/*.md             Markdown posts
    blog/[slug]/+page.haml       /blog/:slug
    feed.xml/+route.rb           /feed.xml

Only klenod.config.rb and src/routes/ have fixed names. The rest is a convention this site follows.

Route files

Routing follows Klenod’s router. Inside src/routes/, a file whose name starts with + has a role:

FileRole
+page.haml, +page.rb or +page.mdthe page at this directory’s path
+layout.hamlwraps every page in this directory and below
+not-found.hamlthe 404 page for this directory and below
+route.rba handler whose return value is written as a file

A directory named in brackets, such as [slug], is a param. See Dynamic routes.

Any other file in src/routes/ is an ordinary module. This site keeps Markdown files in _posts and _pages directories next to the routes that render them. A file there must not start with +.

What the build writes

SourceOutput
routes/+page.hamlindex.html
routes/blog/+page.hamlblog/index.html
routes/feed.xml/+route.rbfeed.xml
routes/+not-found.haml404.html
imported CSS, scripts, images, fontsassets/<name>.<hash>.<ext>
public/robots.txtrobots.txt

Each page is a directory with an index.html, and links to it have no trailing slash: /blog, not /blog/. That works on plain file hosts, and the generated nginx config follows the same rule.

Imports

A module imports another with import, and several with import_glob:

Site = import("/site")                        # src/site.rb
Card = import("./Card.haml")                  # next to this file
Posts = import_glob("./_posts/*.md").values   # every match

A path that starts with / is relative to the source directory. A Ruby module exports the constant named Default.