Astro Website Templates / Static Web Guide
Common Astro Template Setup Problems
Diagnose Astro template installation, content, routing and deployment failures by the stage where the problem first appears.
Diagnose an Astro template setup problem by identifying the first failing stage: dependency installation, development startup, page rendering, production build or deployed behaviour. Record the exact command and first useful error before changing files. Different stages point to different causes.
Keep a working copy or source revision so each attempted fix can be understood and reversed. Updating dependencies, deleting the lockfile and editing configuration at the same time makes the original problem harder to isolate.
The terminal cannot find package.json
Check the current folder and inspect its contents. A downloaded archive may contain an outer packaging folder with the actual project one level deeper. The command must run from the project root containing package.json.
Open that file and inspect its scripts. If npm run dev reports a missing script, the package may use another command or you may be in the wrong project. Do not add arbitrary scripts until you understand the supplied instructions.
The installation guide provides a baseline sequence for an existing template. Follow the package’s actual package manager and lockfile rather than mixing commands from several tutorials.
Dependency installation fails
Start with the first error that explains a dependency, runtime, permission or network failure. Later lines can be consequences of that original failure.
Check the Node version against the package’s documented requirements. Astro major versions and individual dependencies may have different requirements, so use the appropriate versioned documentation. Also verify that the lockfile belongs to the chosen package manager.
If npm ci reports that the lockfile and manifest disagree, establish why before regenerating anything. A partially edited manifest is a source issue; a blocked package download is a network issue. Deleting files does not resolve both in the same way.
The development server starts but cannot be opened
Use the address and port printed by the process. If the preferred port was already in use, the server may have selected another one or reported an error.
In a remote workspace, localhost refers to that environment, not necessarily the computer running your browser. Follow the workspace’s port forwarding or preview instructions. Host binding may be required, but it should be configured deliberately for the environment.
Check that the process is still running. A terminal showing an earlier successful startup does not prove the server has not subsequently stopped after a configuration error.
A component or image import cannot be resolved
Compare the imported path with the real filename, including case and extension. An import that works on a case-insensitive local filesystem can fail on a deployment machine with case-sensitive paths.
Relative source imports are resolved from the importing file. A nested page often needs a different number of parent-directory segments from a root page. Public website paths and source imports are separate concepts.
If the asset lives in public, it is commonly referenced by its public URL rather than imported as a source image. Review the existing package’s image pattern before moving files between public and src.
An article fails metadata validation
Read which collection and field the error names. Check the entry’s frontmatter spelling, required values and data types. A title containing a colon or a date represented inconsistently can expose YAML or schema problems.
Use one valid entry as a structural reference. Do not weaken the schema to accept every malformed value simply to force a build through. Validation is most useful when it preserves a coherent content model.
The content collections guide shows the Astro 5 loader and schema arrangement. If the package uses an older collection convention, follow its migration requirements rather than mixing configurations.
A new page is missing
Determine whether the page should come from a file in src/pages or from a collection-driven dynamic route. Adding Markdown to an arbitrary folder does not automatically create a public route.
For static dynamic routes, inspect the generated path list and the identifier used to build it. Check whether a draft filter, category condition or filename mismatch has excluded the entry.
Then distinguish existence from discovery. A page that opens directly but is absent from navigation needs a listing or link update, not necessarily a new routing configuration.
The build succeeds but types are wrong
A successful build is not equivalent to a dedicated type check. Astro’s TypeScript documentation explains the separate checking workflow.
Inspect the project’s available scripts and use its documented checks. If no check tool is installed, decide deliberately how to add one rather than assuming that an unknown command is available.
Also review errors in context. A layout prop mismatch may indicate that a copied example does not match this package’s component API. Adjust the call to the real component rather than suppressing the type information indiscriminately.
Local preview works but deployment fails
Compare runtime versions, environment variables, build commands and output directories between local and hosting environments. For server-rendered routes, verify the adapter and runtime compatibility.
On the deployed site, test direct access to nested routes and inspect missing asset requests. A homepage loading successfully does not establish that the output directory or base path is correct for every route.
Astro’s official troubleshooting guide provides framework-specific diagnostics. Keep a small reproduction and the exact error available when asking the template author for support.
Verify the fix at the failing stage
Repeat the original failing command after one targeted change. Once it passes, complete the next necessary check, such as a production build or deployed form delivery test.
Use the Astro template overview to connect these technical checks with the package’s documented requirements and maintenance responsibilities.