The EmaSite typeclass “orchestrates” and ties-together the whole site pipeline. The instance is written on the top-level site Route type, which in turn enables using the Ema.runSite function to run the site from main entrypoint of your Haskell project.

%%{init: {'theme': 'forest', "flowchart" : { "curve" : "basis" } } }%%
    direction LR
    dynModel: Dynamic m Model
    SiteArg --> siteInput
    siteInput --> siteOutput : Model
    state siteInput {
      direction LR
    state siteOutput {
      direction LR
    Route --> siteOutput
    siteOutput --> Asset


The SiteArg type specifies the options required to run the site. Typically these come from command line arguments and other environment. The value of this type is passed to the siteInput method of the EmaSite typeclass, as well as taken by the Ema.runSite function (which is called from main).

SiteArg is () by default (meaning, it is unused).


The siteInput method takes a SiteArg value (and other relevant parameters) and returns a Dynamic of the site’s Model type.


The siteOutput method takes the Model type value snapshot at that point in time, as well as the route value to render and returns a Asset output (typically HTML bytestring) for it. siteOutput has IO capabilities; usually it is defined as a pure function (siteOutput ... = pure <expr>) inasmuch as all the data required to render the site is contained in the Model type, but sometimes you may need IO (example).

Note that this method may return a non-Asset type as well (as specified by SiteOutput type). This can be useful in sub-sites that are composed manually at the top-level.

Links to this page
  • Model type
    In EmaSite typeclass, siteInput can now return this model value (and it can be time-varying if using a Dynamic), as well as siteOutput can take the model value so as to render the site based on it.
  • Logging

    The methods of EmaSite support the MonadLoggerIO constraint, as defined by monad-logger. This means that you can use any of the logging functions from monad-logger to add logging to your application. monad-logger-extras is used to colorize the logs.

  • Hello World
    an EmaSite instance on that route type defining the site render pipeline.
  • Guide
  • Dynamic

    The EmaSite’s siteInput method returns a Dynamic of Model type, which represents all the data required to render a site. If you do not want Hot Reload, you may return a pure value.

  • Composing Ema apps

    The composition happens via sub-route composition. i.e., the Route type of your larger Ema app can contain the sub-route type in its sum constructors. If the sub-routes have IsRoute and EmaSite instances, then the corresponding instances for the larger route can be defined in terms of them.

    Ema.Route.Lib.Extra.PandocRoute provides a PandocRoute site that can monitor a directory of LML files (Markdown, org-mode, etc.) and return (in siteOutput of EmaSite) the parsed Pandoc AST along with a function that renders it to HTML.

  • CLI

    The subcommand is passed as the Ema.CLI.Action type to your siteInput function in EmaSite.

  • Asset

    An “asset” is simply a ByteString (written to disk) or FilePath (copied) that siteOutput of EmaSite typically produces. It is defined as: