{"record":{"id":"a02c85ebf0732bb2","repo":"gatsbyjs/gatsby","slug":"pagecreator-to-query-node-gatsbypath-the-filep-a02c85","errorCode":null,"errorMessage":"PageCreator: To query node \"gatsbyPath\" the \"filePath\" argument must omit the src/pages prefix.\nPlease change this to: \"${filePath.replace(/\\/?src\\/pages\\//, ``)}\"","messagePattern":"PageCreator: To query node \"gatsbyPath\" the \"filePath\" argument must omit the src/pages prefix\\.\nPlease change this to: \"(.+?)\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby-plugin-page-creator/src/validate-path-query.ts","lineNumber":22,"sourceCode":"export function validatePathQuery(\n  filePath: string,\n  extensions: Array<string>\n): void {\n  // Paths must start with /\n  if (filePath.startsWith(`/`) !== true) {\n    throw new Error(`PageCreator: To query node \"gatsbyPath\" the \"filePath\" argument must be an absolute path, starting with a /\nPlease change this to: \"/${filePath}\"`)\n  }\n\n  // Paths must not include file extension\n  if (/\\.[a-z]+$/i.test(filePath)) {\n    throw new Error(`PageCreator: To query node \"gatsbyPath\" the \"filePath\" argument must omit the file extension\nPlease change ${filePath} to \"${filePath.replace(/\\.[a-z]+$/i, ``)}\"`)\n  }\n\n  // Paths must not utilize src/pages\n  if (filePath.includes(`src/pages`)) {\n    throw new Error(`PageCreator: To query node \"gatsbyPath\" the \"filePath\" argument must omit the src/pages prefix.\nPlease change this to: \"${filePath.replace(/\\/?src\\/pages\\//, ``)}\"`)\n  }\n\n  // Paths must not include index\n  if (/index$/.test(filePath)) {\n    throw new Error(\n      `PageCreator: To query node \"gatsbyPath\" the \"filePath\" argument must omit index.\nPlease change this to: \"${filePath.replace(/index$/, ``)}\"`\n    )\n  }\n\n  const absolutePath = systemPath.join(process.cwd(), `src/pages`, filePath)\n\n  const file = _.flatten(\n    extensions.map(ext =>\n      [``, `${systemPath.sep}index`].map(index => {\n        try {\n          return require.resolve(absolutePath + index + ext)","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby-plugin-page-creator/src/validate-path-query.ts#L4-L40","documentation":"validatePathQuery's third rule: filePath must NOT include the `src/pages` prefix. Since gatsbyPath always resolves inside src/pages, including it again would double the prefix. The check uses filePath.includes(`src/pages`) so any occurrence (with or without slashes) trips it, and the message shows the prefix-stripped form.","triggerScenarios":"Passing gatsbyPath(filePath: \"/src/pages/about\") or \"/src/pages/blog/post\" - any filePath containing the literal `src/pages`.","commonSituations":"Copying the on-disk path straight from the editor or terminal; migrating queries after moving files into src/pages; auto-path generators that emit project-relative paths.","solutions":["Remove the src/pages portion from filePath, e.g. use \"/about\" instead of \"/src/pages/about\".","If generating paths from __dirname or import.meta.url, strip everything up to and including src/pages.","Use the corrected value shown in the error message."],"exampleFix":"// before\ngatsbyPath(filePath: \"/src/pages/about\")\n\n// after\ngatsbyPath(filePath: \"/about\")","handlingStrategy":"validation","validationCode":"function stripSrcPages(filePath) {\n  if (filePath.includes('src/pages')) {\n    return filePath.replace(/\\/?src\\/pages\\//, '');\n  }\n  return filePath;\n}","typeGuard":"function isBareRoute(p) {\n  return typeof p === 'string' && !p.includes('src/pages');\n}","tryCatchPattern":null,"preventionTips":["Use the route (the URL), not the project-relative file path, in gatsbyPath.","When deriving from __dirname, slice off everything through src/pages."],"tags":["gatsby-plugin-page-creator","graphql","validation","gatsbypath"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}