---
title: "Deploy Astro & Next.js Static Export"
description: "Export and deploy static sites built with Astro, Next.js (output export), Hugo, or Eleventy on Hosted EZ with Clean URLs, Custom 404 pages, and immutable asset headers."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.hostedez.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy Astro & Next.js Static Export

Static site generators like **Astro**, **Next.js (static export)**, **Hugo**, **Eleventy**, and **Docusaurus** pre-render every route into `.html` files at build time. Hosted EZ's **Static Site** runtime serves them directly from nginx with Clean URLs, Custom 404 pages, and path-prefix response headers.

> **Static export vs. Node.js SSR**
>
> Hosted EZ's **Static Site** runtime serves pre-built HTML, CSS, JS, and media files directly from nginx without a Node.js server process. Features that require a live Node.js server (such as Next.js Route Handlers, Middleware, or Astro server adapters) are not supported on Static Sites.

## Framework build configuration

### Astro

Astro defaults to static output (`output: 'static'`) and writes files to `dist/`. Set your production `site` URL in `astro.config.mjs`:

```js title="astro.config.mjs"
import { defineConfig } from "astro/config";

export default defineConfig({
  site: "https://docs.example.com",
  output: "static",
  build: {
    format: "directory", // generates /about/index.html
  },
});
```

Create a custom 404 page at `src/pages/404.astro` so Astro emits `dist/404.html`.

Build and package:

```bash
npm ci
npm run build
zip -r dist.zip dist/
```
### Next.js (Static Export)

Enable static export in `next.config.ts` (or `next.config.mjs`) and set `images.unoptimized: true` (since the built-in Next.js Image Optimization API requires a Node server):

```ts title="next.config.ts"
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  output: "export",
  images: {
    unoptimized: true,
  },
};

export default nextConfig;
```

Create `app/not-found.tsx` (App Router) or `pages/404.tsx` (Pages Router) so Next.js emits `out/404.html`.

Build and package:

```bash
npm ci
npm run build
zip -r out.zip out/
```
### Hugo / Eleventy

Both Hugo (`public/`) and Eleventy (`_site/`) generate static HTML directories ready to archive:

```bash
# Hugo
hugo --minify
zip -r site.zip public/

# Eleventy
npx @11ty/eleventy
zip -r site.zip _site/
```

## Configure Clean URLs, Custom 404 & Headers

1. Create a **Static Site** in [app.hostedez.com](https://app.hostedez.com/dashboard?tab=sites&new=1) and upload your `.zip` or `.tar.gz` archive in the **Deployments** tab.
2. Open **Site → Routing → Static Delivery**:
- **Clean URLs**: turn **On** so `/pricing` resolves `/pricing.html` or `/pricing/index.html` automatically (`try_files $uri $uri.html $uri/ =404;`).
- **SPA fallback**: leave **Off** so genuinely missing URLs return a proper HTTP `404` status (better for SEO).
- **Custom 404 page**: enter `/404.html` (must end with `.html` or `.htm`).

## Recommended Custom Response Headers

Add path-prefix rules in **Routing → Static Delivery → Custom Response Headers** so hashed framework bundles cache aggressively while HTML documents revalidate on every deploy:

### Astro

| Path Prefix | Header | Value |
| --- | --- | --- |
| `/` | `Cache-Control` | `no-cache, must-revalidate` |
| `/` | `Referrer-Policy` | `strict-origin-when-cross-origin` |
| `/` | `X-Frame-Options` | `SAMEORIGIN` |
| `/_astro` | `Cache-Control` | `public, max-age=31536000, immutable` |
### Next.js Static Export

| Path Prefix | Header | Value |
| --- | --- | --- |
| `/` | `Cache-Control` | `no-cache, must-revalidate` |
| `/` | `Referrer-Policy` | `strict-origin-when-cross-origin` |
| `/` | `X-Frame-Options` | `SAMEORIGIN` |
| `/_next/static` | `Cache-Control` | `public, max-age=31536000, immutable` |

> **Do not enable both SPA fallback and Custom 404**
>
> When **SPA fallback** is enabled, unmatched paths rewrite to `/index.html` with HTTP `200`, so a Custom 404 page is only reached for missing static files. For Astro and Next.js static exports, keep **SPA fallback** off and use **Clean URLs** + **Custom 404 page** (`/404.html`).

## Next steps

- Automate builds and deployments on every push with [SFTP & GitHub Actions CI/CD](/deploy/sftp-and-github-actions).
- Add permanent `301`/`308` redirects for moved pages in [Redirects, Password Protection & Maintenance Mode](/domains/redirects-auth-maintenance).
- Review all 15 allowlisted custom headers in [SPA Routing, Clean URLs & Custom Headers](/domains/spa-routing-and-headers).

Source: https://docs.hostedez.com/deploy/astro-nextjs-static/index.mdx
