Dynamic routes
A route with params, such as blog/[slug], cannot be listed from the file
system alone. The page says which values to pre-render in
self.static_params, one hash per page:
:ruby
Posts = import_glob("../_posts/*.md").values
def self.static_params
Posts.map { {slug: it::Frontmatter.fetch(:slug)} }
end
:ruby
post = Posts.find { it::Frontmatter.fetch(:slug) == $request.params.fetch(:slug) }
%title= post::Frontmatter.fetch(:title)
%article
= Rista::H[post]
The first :ruby block runs once, when the module loads. The second runs for
each page, and reads the params from $request.params.
A route with params and no static_params fails the build.
Several params
A route can have several params. This site serves posts at paths such as
/blog/2026/11/03/introducing-rista, from
blog/[year]/[month]/[day]/[slug]/+page.haml. Its static_params returns one
{year:, month:, day:, slug:} hash per post.
The year and month archives at /blog/2026 and /blog/2026/11 are the
+page.haml files in the directories above it. Each lists the years or months
that have posts:
def self.static_params
Posts.years.map { {year: it} }
end
Param values
Param values go into paths and file names as they are given. Keep them
URL-safe: static-sites, not Static sites. They are case-sensitive.
A param value must not make a path that belongs to another route. That is a build error, and so is a hash that leaves out one of the route’s params.
Handlers
A +route.rb under a param directory defines self.static_params the same
way. See Files from routes.