{"record":{"id":"6eef103dbc8fea50","repo":"withastro/astro","slug":"pagenumberparamnotfound","errorCode":"PageNumberParamNotFound","errorMessage":"[paginate()] page number param `${paramName}` not found in your filepath.","messagePattern":"\\[paginate\\(\\)\\] page number param `(.+?)` not found in your filepath\\.","errorType":"validation","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/core/render/paginate.ts","lineNumber":36,"sourceCode":"): (...args: Parameters<PaginateFunction>) => ReturnType<PaginateFunction> {\n\treturn function paginateUtility(\n\t\tdata: readonly any[],\n\t\targs: PaginateOptions<Props, Params> = {},\n\t): ReturnType<PaginateFunction> {\n\t\tconst generate = getRouteGenerator(routeMatch.segments, trailingSlash);\n\t\tlet { pageSize: _pageSize, params: _params, props: _props, format: _format } = args;\n\t\tconst pageSize = _pageSize || 10;\n\t\tconst paramName = 'page';\n\t\tconst additionalParams = _params || {};\n\t\tconst additionalProps = _props || {};\n\t\tconst formatUrl = _format || ((url: string) => url);\n\t\tlet includesFirstPageNumber: boolean;\n\t\tif (routeMatch.params.includes(`...${paramName}`)) {\n\t\t\tincludesFirstPageNumber = false;\n\t\t} else if (routeMatch.params.includes(`${paramName}`)) {\n\t\t\tincludesFirstPageNumber = true;\n\t\t} else {\n\t\t\tthrow new AstroError({\n\t\t\t\t...AstroErrorData.PageNumberParamNotFound,\n\t\t\t\tmessage: AstroErrorData.PageNumberParamNotFound.message(paramName),\n\t\t\t});\n\t\t}\n\t\tconst lastPage = Math.max(1, Math.ceil(data.length / pageSize));\n\n\t\tconst result = [...Array(lastPage).keys()].map((num) => {\n\t\t\tconst pageNum = num + 1;\n\t\t\tconst start = pageSize === Number.POSITIVE_INFINITY ? 0 : (pageNum - 1) * pageSize; // currentPage is 1-indexed\n\t\t\tconst end = Math.min(start + pageSize, data.length);\n\t\t\tconst params = {\n\t\t\t\t...additionalParams,\n\t\t\t\t[paramName]: includesFirstPageNumber || pageNum > 1 ? String(pageNum) : undefined,\n\t\t\t};\n\t\t\tconst current = formatUrl(addRouteBase(generate({ ...params }), base));\n\t\t\tconst next =\n\t\t\t\tpageNum === lastPage\n\t\t\t\t\t? undefined","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/core/render/paginate.ts#L18-L54","documentation":"Thrown by paginate() when the route's filename does not contain a 'page' dynamic segment. paginate() generates URLs for each page by substituting a param literally named 'page', so the filepath must declare [page] or [...page] for it to inject the number.","triggerScenarios":"Calling paginate() inside getStaticPaths() of a file named e.g. [id].astro or blog.astro that has no [page] segment; renaming the file but forgetting to update the param; using a custom paramName is not supported — paginate() hardcodes 'page'.","commonSituations":"Following a pagination tutorial on a route whose filename lacks the [page] param; converting a non-paginated route to paginated without renaming the file; expecting paginate() to work on [...slug].astro rest routes.","solutions":["Rename the route file so it contains [page], e.g. src/pages/blog/[page].astro.","For catch-all pagination use [...page].astro.","Verify routeMatch.params includes 'page' or '...page' before relying on paginate()."],"exampleFix":"// before — file: src/pages/blog.astro\nexport async function getStaticPaths() {\n  return paginate(getCollection('posts'), { pageSize: 10 });\n}\n\n// after — rename file to src/pages/blog/[page].astro\nexport async function getStaticPaths() {\n  return paginate(getCollection('posts'), { pageSize: 10 });\n}","handlingStrategy":"validation","validationCode":"const PAGE_PARAM = 'page';\nfunction routeHasPageParam(params: string[]): boolean {\n  return params.includes(PAGE_PARAM) || params.includes(`...${PAGE_PARAM}`);\n}\n// only call paginate() when this returns true","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Name paginated routes [page].astro or [...page].astro by convention.","Add a lint/code-review check that paginate() is only called in files containing the [page] segment.","Remember paginate() hardcodes the 'page' param name — it is not configurable."],"tags":["pagination","routing","getstaticpaths","filesystem"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}