gatsbyjs/gatsby · error
PageCreator: To query node "gatsbyPath" the "filePath" argum
Error message
PageCreator: To query node "gatsbyPath" the "filePath" argument must omit index.
Please change this to: "${filePath.replace(/index$/, ``)}" What it means
validatePathQuery's fourth rule: filePath must NOT end with `index`. The regex /index$/ matches a trailing `index` (the conventional filename for the root of a route). Because the route root is the directory itself, the filePath should stop at the directory. The message shows the index-stripped form.
Source
Thrown at packages/gatsby-plugin-page-creator/src/validate-path-query.ts:28
throw new Error(`PageCreator: To query node "gatsbyPath" the "filePath" argument must be an absolute path, starting with a /
Please change this to: "/${filePath}"`)
}
// Paths must not include file extension
if (/\.[a-z]+$/i.test(filePath)) {
throw new Error(`PageCreator: To query node "gatsbyPath" the "filePath" argument must omit the file extension
Please change ${filePath} to "${filePath.replace(/\.[a-z]+$/i, ``)}"`)
}
// Paths must not utilize src/pages
if (filePath.includes(`src/pages`)) {
throw new Error(`PageCreator: To query node "gatsbyPath" the "filePath" argument must omit the src/pages prefix.
Please change this to: "${filePath.replace(/\/?src\/pages\//, ``)}"`)
}
// Paths must not include index
if (/index$/.test(filePath)) {
throw new Error(
`PageCreator: To query node "gatsbyPath" the "filePath" argument must omit index.
Please change this to: "${filePath.replace(/index$/, ``)}"`
)
}
const absolutePath = systemPath.join(process.cwd(), `src/pages`, filePath)
const file = _.flatten(
extensions.map(ext =>
[``, `${systemPath.sep}index`].map(index => {
try {
return require.resolve(absolutePath + index + ext)
} catch (e) {
return false
}
})
)
).filter(Boolean) as Array<string>View on GitHub (pinned to 8b06340921)
Solutions
- Drop the trailing `index`, e.g. use "/about/" or "/about" instead of "/about/index".
- Strip it programmatically when generating paths: filePath.replace(/index$/, '').
- Use the value suggested in the error message.
Example fix
// before gatsbyPath(filePath: "/about/index") // after gatsbyPath(filePath: "/about/")
Defensive patterns
Strategy: validation
Validate before calling
function stripTrailingIndex(filePath) {
return /index$/.test(filePath) ? filePath.replace(/index$/, '') : filePath;
} Type guard
function hasNoTrailingIndex(p) {
return typeof p === 'string' && !/index$/.test(p);
} Prevention
- Do not append /index to gatsbyPath filePath; end at the directory.
- Filter 'index' out of any generated route segments.
When it happens
Trigger: Passing gatsbyPath(filePath: "/about/index") or "/blog/index") - any filePath ending in the word index.
Common situations: Translating the actual index.js/index.tsx filename into the query; building the path from the file basename without filtering `index`; coming from frameworks where /about/index is the canonical route.
Related errors
- PageCreator: To query node "gatsbyPath" the "filePath" argum
- PageCreator: To query node "gatsbyPath" the "filePath" argum
- PageCreator: To query node "gatsbyPath" the "filePath" argum
- PageCreator: To query node "gatsbyPath" the "filePath" argum
- Invalid plugin options for "gatsby-plugin-feed": "quer
AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13).
Data as JSON: /api/errors/d7ac089a41e17502.
Report an issue: GitHub.