Skip to content

Static Sites

Railpack can automatically build and setup a server for static sites that require no build steps. The Caddy server is used as the underlying web server.

Your project will be automatically detected as a static site if any of these conditions are met:

  • A Staticfile configuration file exists in the root directory
  • An index.html file exists in the root directory
  • A public directory exists
  • The RAILPACK_STATIC_FILE_ROOT environment variable is set

The provider determines the root directory in this order:

  1. RAILPACK_STATIC_FILE_ROOT environment variable if set
  2. root directory specified in Staticfile if present
  3. public directory if it exists
  4. Current directory (.) if index.html exists in root

You can configure the root directory with a Staticfile that contains the contents:

# root directory to serve
root: dist
VariableDescriptionExample
RAILPACK_STATIC_FILE_ROOTOverride the root directorypublic

Railpack uses a custom Caddyfile that is used to serve the static files. You can overwrite this file with your own Caddyfile at the root of your project.