Skip to content
/ Saga Public

A code-first static site generator in Swift. No config files, no implicit behavior, no magic conventions.

License

Notifications You must be signed in to change notification settings

loopwerk/Saga

Repository files navigation

Saga

A code-first static site generator in Swift. No config files, no implicit behavior, no magic conventions.

Your entire site pipeline is plain Swift code:

try await Saga(input: "content", output: "deploy")
  .register(
    folder: "articles",
    metadata: ArticleMetadata.self,
    readers: [.parsleyMarkdownReader],
    writers: [
      .itemWriter(swim(renderArticle)),
      .listWriter(swim(renderArticles), paginate: 20),
      .tagWriter(swim(renderTag), tags: \.metadata.tags),
    ]
  )
  .run()
  .staticFiles()

Typed metadata, pluggable readers, multiple writer types, pagination, tags — all defined in Swift, readable top to bottom, and enforced by the compiler. No hidden defaults. No template logic you can't debug.

Who this is for

Saga is for you if:

  • You want your site generation logic in Swift, not YAML/TOML config files
  • You want compile-time safety for your content metadata
  • You've outgrown convention-based SSGs and want full control

Saga is not for you if:

  • You want a CLI that scaffolds everything with zero code
  • You need a large ecosystem of themes and templates
  • You're not comfortable with Swift

Getting started

Getting started takes a few minutes if you're comfortable with Swift and SwiftPM. Follow the installation guide to set up your first site.

Code over configuration

Saga avoids hidden behavior entirely.

There are no default values to override, no magic conventions you have to learn, and no configuration files that quietly change how your site is built. Everything is strongly typed, from top to bottom, and you describe exactly how your site is generated using Swift code.

If something happens during a build, you can always point to the code that made it happen.

Growing beyond a simple site

The example above shows a single content type, but Saga scales to handle complex sites with multiple content types.

Saga allows you to:

  • Add strongly typed metadata to your content
  • Define multiple content types with different metadata
  • Build archive pages, tag pages, feeds, and indexes
  • Swap in different readers and renderers
  • Keep everything enforced by the compiler

Typed metadata (when you need it)

Saga's metadata system lets you define multiple content types, each with their own strongly typed metadata.

For example, a single site might include:

  • Blog articles with tags and publication dates
  • A project portfolio with App Store links and screenshots
  • Movie reviews with ratings, actors, genres, and release years

Each content type can be indexed, paginated, or grouped independently.

Few static site generators can model diverse content like this while keeping everything type-safe. Saga can.

See the Example project for a complete site with articles, server-side syntax highlighting of code blocks, tags, pagination, an app portfolio, and RSS feeds.

Documentation

Full documentation covering installation, getting started, metadata modeling, and advanced usage is available:

Plugins

Saga is modular. You compose it with readers and renderers that fit your needs.

Markdown readers

Renderers

Requirements

Saga requires Swift 5.5+ and runs on macOS 12+ and Linux. The development server requires browser-sync and only works on macOS.

Websites using Saga

Is your website built with Saga? Send a pull request to add it to the list!

Support

Commercial support is available via Loopwerk.

About

A code-first static site generator in Swift. No config files, no implicit behavior, no magic conventions.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Contributors 3

  •  
  •  
  •  

Languages