Skip to content

Repository files navigation

Distilled

A static site generator for Elixir. Write pages as Markdown, style them with HEEx templates and Phoenix function components, and build a plain static site — with a dev server and live reload while you work.

Create a new site

Distilled ships an Igniter installer, so a new site is one command:

mix archive.install hex igniter_new     # one-time, if you don't have it
mix igniter.new my_site --install distilled

This scaffolds a ready-to-build site: config/config.exs, a starter theme in theme/ (HEEx layouts plus a MySite.Components module), and a first page in content/.

Then:

cd my_site
mix distilled.server   # dev server with live reload at http://localhost:4000
mix distilled.build    # build the static site into out/

Add to an existing project

mix igniter.install distilled

Or add it manually to your mix.exs and run the installer:

def deps do
  [
    {:distilled, "~> 0.1.0"},
    {:phoenix_live_view, "~> 1.2"}
  ]
end
mix deps.get
mix distilled.install

How it works

  • content/ — Markdown files with optional YAML front matter. Directory structure is preserved in the output.
  • theme/ — the site's theme: HEEx layouts plus a Phoenix.Component module. Front matter layout: picks a layout per page; config :distilled, layout: sets the default. The rendered page HTML is available as @content, front matter as @page, and the site index as @site. theme/ is on the compile path (elixirc_paths) so its components module compiles.
  • Components — define one or more modules (e.g. MySite.Components, MySite.UI) in theme/ using Phoenix.Component, list them in config :distilled, components: [...], and call their functions (<.meta_tags />, <.callout>…</.callout>) from any layout. Every listed module's function is imported, so you can split components across files.
  • out/ — the built static site.

Local development / testing the generator

Until Distilled is published to Hex, you can still run the installer against a local checkout by giving --install a @path: source pointing at this repo:

mix igniter.new my_site --install "distilled@path:/absolute/path/to/distilled"

Two gotchas worth knowing:

  • Run it outside any Mix project. mix igniter.new bootstraps igniter by manipulating the current Mix project state, so running it from inside an existing project (e.g. distilled/ or distilled/example/) fails with cannot retrieve dependencies information because dependencies were not loaded. Run it from a plain directory with no mix.exs above it.

  • Skip igniter.new entirely if you prefer. Scaffold a bare project and run the installer directly — this avoids the bootstrap step altogether:

    mix new my_site && cd my_site
    # add {:igniter, "~> 0.8"} to deps in mix.exs, then:
    mix deps.get
    mix igniter.install "distilled@path:/absolute/path/to/distilled"

The installer itself is covered by test/mix/tasks/distilled.install_test.exs, which runs without any of the above via Igniter's test helpers:

mix test test/mix/tasks/distilled.install_test.exs

Documentation

Docs can be generated with ExDoc and, once published, will be at https://hexdocs.pm/distilled.

About

Developer-friendly static site generator built in Elixir.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages