Islands and deployment
Deploy a static Astro site
Upload the build output to a static host and verify the real production URL, redirects, and fallback behavior.
8 minute lesson
A static Astro deployment has two essential settings:
Build command: npm run build
Publish directory: dist
The host builds the project and serves the generated files. A purely static site does not need an Astro server adapter. Add an adapter only when you use on-demand routes or a platform feature that requires one.
Set the production origin when Astro must generate absolute URLs:
import { defineConfig } from "astro/config"
export default defineConfig({
site: "https://example.com"
})
Build-time environment variables must exist in the host’s build settings. Runtime secrets matter only when a deployed server function reads them. Confusing these lifetimes is a common reason a local build works while production fails.
After deployment, test the real domain. Check a nested route, an unknown route, redirects, canonical URLs, image assets, and endpoint status codes. Inspect response headers because caching and redirect behavior belong to the host as well as your code.
Finally, load one island with throttling and with JavaScript disabled. The production Network panel—not the source tree—shows what the visitor actually pays for.
Lesson completed