A static export needs every route decided at build time
Problem
The site is a static export, so every page and file must exist when the build ends. Two routes broke that rule in different ways. The icon route, drawn in code, was treated as something to make on request. The lessons route took a name from the address, and with no lessons written yet it had no names to generate.
Symptoms
- The build failed on the icon with a complaint that it could not be exported.
- The build failed on the dynamic lessons route because it generated no pages at all.
What Didn't Work
- Leaving the icon route to default behaviour. The default allowed it to be made on request, which a static export cannot do.
- Letting the lessons route generate an empty list. A dynamic route with no pages to generate was refused.
Solution
The icon was marked as built once with the site:
export const dynamic = "force-static"
The lessons route generated one placeholder page, with a plain line saying there was no lesson yet, while the folder of lessons was empty. Nothing linked to the placeholder, and the placeholder was removed as soon as the first lesson existed. Tests that scanned the built pages were told about the placeholder while it lasted.
Why This Works
A static export has no server to answer a request later. Whatever the site serves must be fixed by the end of the build, so each route has to say either that it is static or exactly which pages it produces.
Prevention
- Mark any generated file route, such as an icon or share image, as static.
- Give every dynamic route at least one page to generate, or a deliberate placeholder.
- Build early in a task that adds a route, not only at the end, so the refusal appears while the change is small.
- Remove a placeholder as soon as the real content exists, and keep tests from depending on it.