Troubleshooting
This page covers common issues you may encounter when working with Pagesmith and how to resolve them.
Tip
AI quick-start: Describe your Pagesmith error to your AI agent for diagnosis. Paste the error message and the agent can identify the root cause and suggest a fix.
Dev Server Issues
Dev server doesn’t reload on file changes
Symptoms: You edit a markdown file or configuration file, but the browser does not refresh.
Causes and solutions:
-
File is outside
contentDir. The dev server watches only the content directory configured inpagesmith.config.json5. Verify your file is inside the correct directory:{ contentDir: "./content", // Files must be under this path}The default
contentDirisdocs/if that directory exists, otherwisecontent/. Check which applies to your project. -
Syntax error in frontmatter. A YAML parsing error in frontmatter can cause the build to fail silently. Check for common YAML issues:
---# Missing quotes around values with colonstitle: Getting Started: A Guide # Needs quotestitle: "Getting Started: A Guide" # Correct# Incorrect indentationhero:title: My Site # Wrong -- needs indentation title: My Site # Correct--- -
File watcher limit reached. On Linux, the default
inotifywatch limit may be too low. Increase it:echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.confsudo sysctl -p
Build Errors
Build fails with “cannot find module virtual:content/…”
Symptoms: The build or dev server crashes with an error like:
Error: Cannot find module 'virtual:content/posts'Causes and solutions:
-
Collection name mismatch. The virtual module name must match the collection name in your
content.config.tsexactly:const posts = defineCollection({ loader: "markdown", directory: "content/posts",});export default defineConfig({ collections: { posts }, // This name must match the import});// Must match the key in collectionsimport posts from "virtual:content/posts"; // Correctimport blog from "virtual:content/blog"; // Wrong -- no collection named 'blog' -
Missing
content.config.ts. The Vite pluginpagesmithContentlooks for this file at the project root. Ensure it exists and exports a valid config. -
Plugin not registered. Ensure the
pagesmithContentVite plugin is in yourvite.config.ts:import { pagesmithContent } from "@pagesmith/site/vite";import { defineConfig } from "vite";export default defineConfig({ plugins: [pagesmithContent()],});
Build fails with validation errors
Symptoms: The build reports schema validation errors for your content entries.
Causes and solutions:
-
Required field missing. If you use
BaseFrontmatterSchemaorBlogFrontmatterSchema, fields liketitle,description, andpublishedDateare required:---title: My Post# Missing 'description' and 'publishedDate' -- will fail validation---Add the missing fields or make them optional in a custom schema:
const posts = defineCollection({ schema: z.object({ title: z.string(), description: z.string().optional(), // Now optional }),}); -
Type mismatch. A field value does not match the expected type. Common cases:
---# order expects a number, not a stringorder: "first" # Wrongorder: 1 # Correct# tags expects an arraytags: javascript # Wrong -- this is a stringtags: # Correct -- this is an array - javascript---
Search Issues
Search isn’t working
Symptoms: The search modal opens (via Ctrl+K / Cmd+K) but returns no results, or the search UI does not appear at all.
Causes and solutions:
-
Search index not built. Pagefind generates its index during
pagesmith-docs build, not during development. Run a full build first:pagesmith-docs buildpagesmith-docs previewDuring
pagesmith-docs dev, search is not available because the Pagefind index has not been generated. -
Search disabled in config. Check that search is enabled:
{ search: { enabled: true, // Default is true },} -
Content not indexed. Pagefind indexes the built HTML output. If pages are marked as
draft: true, they are excluded from the build and will not appear in search results.
Layout Issues
Custom layout isn’t being used
Symptoms: You created a custom layout component, but pages still render with the default layout.
Causes and solutions:
-
Layout not registered in config. Custom layouts must be declared in the
theme.layoutsconfig:{ theme: { layouts: { home: "./theme/layouts/CustomHome.tsx", page: "./theme/layouts/CustomPage.tsx", }, },} -
Export name mismatch. The layout module must export the component as
defaultor one of the recognized named exports:Layout Key Accepted Exports homedefault,DocHome,Homepagedefault,DocPage,PagenotFounddefault,DocNotFound,NotFound// Either of these works:export default function CustomPage(props) { ... }export function DocPage(props) { ... } -
Section-level layout not registered. If you set
layoutoritemLayoutin a section’smeta.json5, the layout name must also be a key intheme.layouts:{ displayName: "Blog", itemLayout: "blog-post", // Must exist in theme.layouts}{ theme: { layouts: { "blog-post": "./theme/layouts/BlogPost.tsx", }, },}
Content Issues
Images not appearing
Symptoms: Images referenced in markdown do not display in the rendered page.
Causes and solutions:
-
Incorrect relative path. Image paths in markdown are relative to the markdown file’s directory. For folder-based content, place images next to the
README.md:content/ guide/ getting-started/ README.md screenshot.png <- Same directory as README.md -
Image outside content directory. The build copies companion assets (images referenced from markdown) from the content directory. Images placed outside
contentDirare not discovered. -
Unsupported format. The asset copier recognizes these extensions:
.svg,.png,.jpg,.jpeg,.gif,.webp,.avif,.ico. Other formats are ignored. -
Public directory images. For images shared across many pages, place them in
publicDir(default:public/) and reference with an absolute path:
Validation errors but frontmatter looks correct
Symptoms: The build reports validation errors even though the frontmatter YAML appears correct.
Causes and solutions:
-
Schema type expectations. Check the schema definition for the exact types expected. Zod is strict about types:
---# publishedDate must be a valid datepublishedDate: not-a-date # FailspublishedDate: 2026-01-15 # Works# order must be a numberorder: 1.5 # Works (it's a number)order: "1" # May fail depending on schema--- -
Required vs. optional fields.
BaseFrontmatterSchemarequirestitle,description, andpublishedDate. TheDocsFrontmatterSchemaused by@pagesmith/docsmakes all fields optional. If you see “required” errors, check which schema is active. -
Extra fields with strict schemas. If your custom schema does not use
.passthrough(), extra frontmatter fields cause validation failures:// Strict -- extra fields rejectedconst schema = z.object({ title: z.string() });// Passthrough -- extra fields preservedconst schema = z.object({ title: z.string() }).passthrough();
Git-Based Features
lastUpdated shows wrong date
Symptoms: The “Last updated” timestamp on a page does not match when you last edited the file.
Causes and solutions:
-
File not committed. The
lastUpdatedfeature reads the git log withgit log -1 --format=%cI. Uncommitted changes are not reflected. Commit your changes to update the timestamp. -
Shallow clone. CI environments often use shallow clones (
git clone --depth 1), which only include the most recent commit. All pages will show the same date. Use a full clone or increase the depth:- uses: actions/checkout@v4 with: fetch-depth: 0 # Full history for accurate timestamps -
Feature not enabled. Ensure
lastUpdatedis enabled in your config:{ lastUpdated: true,} -
Git not available. If
gitis not on the system PATH during the build, the timestamp silently falls back toundefinedand no date is shown.
Configuration Issues
Config file not found
Symptoms: The CLI exits with:
No pagesmith.config.json5 file found at /path/to/pagesmith.config.json5Causes and solutions:
-
Wrong working directory. The CLI looks for the config file relative to the current working directory. Run the command from your project root, or specify the path:
pagesmith-docs dev --config ./pagesmith.config.json5 -
File not created yet. Run
pagesmith-docs initto create the initial config file:pagesmith-docs init
Base path not applied correctly
Symptoms: Links and assets break when deploying to a subdirectory (e.g. GitHub Pages with a repository name prefix).
Causes and solutions:
The base path follows a priority chain:
--base-pathCLI flag (highest priority)BASE_URLenvironment variablebasePathinpagesmith.config.json5- Default:
"/"
Ensure you set it in exactly one place. For GitHub Pages:
pagesmith-docs build --base-path /my-repoOr in CI:
BASE_URL=/my-repo pagesmith-docs build