Skip to Content

Deployment

Build your site and put it online.

astro build writes the site to dist/. Without an adapter, the whole site is static, so deploy it to any static host. With an adapter, your output and prerender settings work as they do in Astro.

Pages of a static source are prerendered. Pages of a dynamic source, like Notion, render on demand, and one site can mix both. Files generated from your content, like .md files, the sitemap and Open Graph images, use the same render mode as their pages.

What Needs a Server

Without an adapter, the build fails on anything in this list and prints the reason.

A plugin with middleware doesn't fail the build. Without an adapter, the build warns that its middleware never runs.

Render Mode

The mode option of createPress() changes when content renders, for every source or by source key:

press.config.tsx
createPress(
  {
    docs: docsSource,
    guides: notion.dynamicSource({ baseDir: "guides" }),
  },
  { mode: { guides: "force-static" } },
);
  • auto: the default described above.
  • force-dynamic: render on demand, so that every request reaches middleware, like for authentication.
  • force-static: load a dynamic source once at build time, and prerender its pages.

With output: "server", auto renders every source on demand, like other Astro routes. To build a dynamic source without an adapter, set mode: "force-static".

Cache Headers

A dynamic source with staleTime, in milliseconds, is read again once that time has passed. Its pages rendered on demand, with their .md file and Open Graph image, get Cache-Control: public, s-maxage=<staleTime in seconds>, so a CDN keeps them for the same time:

press.config.tsx
createPress({ ...notion.dynamicSource(), staleTime: 60_000 });

Without staleTime, Fumapress sets no Cache-Control.

Adapters

Add an adapter to render routes on demand. Pages of static sources stay prerendered.

astro.config.mjs
export default defineConfig({
  site: "https://acme.dev",
  adapter: node({ mode: "standalone" }), 
  integrations: [press()],
});

With the Node.js adapter, start the server with NODE_ENV=production. Without it, React runs its development build on the server.

NODE_ENV=production node dist/server/entry.mjs

Rendering Every Page on Demand

With output: "server", pages of static sources render on demand too, unless mode prerenders them. Use it when every page must run middleware, like authentication.

astro.config.mjs
export default defineConfig({
  output: "server", 
  adapter: node({ mode: "standalone" }),
  integrations: [press()],
});

Post-Build Plugins

Plugins like link validation read the pages that Astro prerenders during the build. A build that prerenders elsewhere, with experimental.parallelPrerender or an adapter prerendering outside of Node.js, fails and prints the reason.

Files written by these plugins go to your Astro outDir, which is public on a static host.

Base Path

For a URL like https://user.github.io/repo/, set site and base:

astro.config.mjs
export default defineConfig({
  site: "https://user.github.io",
  base: "/repo",
  integrations: [press()],
});

page.url and other loader paths don't include base, so use withBase() on custom pages.

Build Errors

The build stops with one of these messages:

Last updated on

On this page