Skip to content

Deploy Astro & Next.js Static Export

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.

Updated View as Markdown

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.

Framework build configuration

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

astro.config.mjsjs
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:

npm ci
npm run build
zip -r dist.zip dist/

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):

next.config.tsts
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:

npm ci
npm run build
zip -r out.zip out/

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

# 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 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).
Static Delivery and Custom Response Headers configuration in Hosted EZ Routing tabStatic Delivery and Custom Response Headers configuration in Hosted EZ Routing tab

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

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
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

Next steps

Navigation

Type to search…

↑↓ navigate↵ selectEsc close