# pages System pages: central assignment of roles (homepage / notFound / privacyPolicy / cookiePolicy / termsOfService) to documents in the client's Pages collection, in SiteSettings. The front end resolves a role to a locale-aware path. ## Config (payload.config.ts) ```ts ipalKit({ pages: { slug: 'pages', // the slug of your Pages collection // roles: ['homepage', 'privacyPolicy', 'cookiePolicy'], // default: all }, }) ``` | Option | Default | What it does | |---|---|---| | `slug` | — (required) | slug of the client's Pages collection | | `roles` | all (`ALL_SYSTEM_PAGE_ROLES`) | which roles to show as fields | Adds a **System pages** tab in SiteSettings with relationship fields (field name = role: `homepage`, `notFound`, `privacyPolicy`, `cookiePolicy`, `termsOfService`) to your Pages collection. The editor picks which document plays which role. The plugin does not know your collection — you give the slug in the option. The `pages` option also turns on the **Maintenance** tab ([construction.md](./construction.md)) and is required by `content`. ## Front end — resolving a role's path ```ts import { getSystemPagePath } from '@intecion/ipal-kit' // SiteSettings with locale:'all' + depth:1 (so the relationship is an object, not an ID) const settings = await payload.findGlobal({ slug: 'site-settings', locale: 'all', depth: 1, }) // homepage in locale 'pl' getSystemPagePath({ page: settings.homepage, locale: 'pl', config }) // → '/pl' (the home slug collapses to the root) or '/pl/strona-glowna' // privacy policy in 'en' getSystemPagePath({ page: settings.privacyPolicy, locale: 'en', config }) // → '/en/privacy-policy' ``` Returns `undefined` when the role is unassigned or the document has no slug in the given locale — the caller decides the fallback (404, redirect). A slug equal to `homeSlug` (default `'home'`; a string or a per-language map) collapses to the root — for a home page with a different slug, pass `homeSlug`. **Pages with no URL of their own:** `unlistedPageIds(settings)` (root) → the ids of pages assigned to a role that renders elsewhere — today the 404 page (unless it is also the homepage). The sitemap, llms.txt, the site index (MCP `list_pages`) and search (`searchContent`, `createSearchRoute`, MCP `search_content`) leave them out; use it in your own lists of pages too. ## Typical case: `/{locale}` → home page In the `[locale]/page.tsx` route you read `settings.homepage`, take its slug in the current locale and render that document. The privacy policy link in the footer / cookie banner comes from `getSystemPagePath({ page: settings.privacyPolicy, locale, config })` — or, simpler, `getSystemLinks(locale)` from `@/lib/content` (href + page title, see links.md). ## Roles ```ts import { ALL_SYSTEM_PAGE_ROLES } from '@intecion/ipal-kit' // ['homepage', 'notFound', 'privacyPolicy', 'cookiePolicy', 'termsOfService'] ``` ## 404 page — chosen in the admin panel (since 1.7.12) Site settings → System pages → **404 (Not Found)**. The editor picks: - a dedicated "Not found" page (e.g. slug `strona-nie-znaleziona`), **or** - the home page (some clients prefer that), **or** - nothing → the project shows the built-in fallback from `not-found.tsx`. Project — two files in `app/(frontend)/[locale]/` (since 1.12.0, **lazy variant — recommended**): ```ts // notFoundView.ts — server action with the 404 content in ONE language 'use server' import { renderNotFoundView } from '@intecion/ipal-kit/rsc' import * as content from '@/lib/content' import { blockRegistry } from '@/blocks/registry' export async function loadNotFoundView(locale: string) { return renderNotFoundView(content, { blocks: blockRegistry, fallback:

404

, // when no 404 page is chosen in the admin panel (or per language: (locale) => …) // blockProps: async ({ locale }) => ({ formTexts: await content.getFormTexts(locale), sendForm }), }, locale) } ``` ```tsx // not-found.tsx import { createNotFoundPage } from '@intecion/ipal-kit/rsc' import * as content from '@/lib/content' import { loadNotFoundView } from './notFoundView' export default createNotFoundPage(content, { load: loadNotFoundView }) ``` (`fallback` with JSX → file `notFoundView.tsx`.) **Why lazy:** Next puts the layout's `not-found` tree into the RSC data (`self.__next_f`) of **every** page under it — the router needs it for a client-side 404. The immediate variant renders the 404 page from the admin panel there in every language, so every page carries it in its HTML (404 = home page with 2 languages: home page HTML 195 → 146 KB gzip, contact page 153 → 104 KB). In the lazy variant the data holds only `` (`/client`); the content arrives from the server action only when the 404 is shown. Language from the URL (`/en/...`); `renderNotFoundView` accepts only configured languages (others → the default). The 404 status is unchanged; the content appears after hydration (the 404 page is not indexed anyway). Immediate variant (the only one up to 1.11.x) — content already in the HTML, at the cost of every page's size: ```tsx export default createNotFoundPage(content, { blocks: blockRegistry, fallback:

404

}) ``` It does exactly what the full file below does (a view for every language + `LocaleView`, no `headers()`). Every page block gets `locale`, the `blockProps` result and **`isFirst`** (1.11.0) — `true` for the first section: its heading is the page's only `h1` (``), the others give `h2`. The catch-all page with the same helpers: `createPageRoute(content, { blocks, notFound, permanentRedirect, blockProps, render, jsonLd, layoutField, redirect, onMissing, homeAlias })` — PROGRAMISTA §2.8. Returns `{ Page, generateMetadata, generateStaticParams }`. `render` gives your own view for an archive or entry (`route.type`: `page | home | archive | entry`), the rest stays default. `jsonLd` (default `true`) adds `` from `getPageJsonLd`; `layoutField` — the blocks field (`'layout'`). The route always resolves page 1 — it does not handle `?page=` (archive pagination: content.md). Full options: [frontend.md](./frontend.md). The `redirect` option (from `next/navigation`) turns on under-construction mode — [construction.md](./construction.md). **Missing page → home page** (1.11.1): `onMissing: 'redirectHome'` (needs `redirect`) — a URL with no page and no old slug (e.g. a retired `/pl/uslugi`) redirects (307) to the home page in the same language (System pages → Homepage). No home page assigned, or the home page itself missing → a plain 404. Default `'notFound'`; your own decision: `onMissing: ({ locale, segments }) => redirect(…)`. ```tsx const route = createPageRoute(content, { blocks: blockRegistry, notFound, permanentRedirect, redirect, onMissing: 'redirectHome' }) ``` **Home page under its own slug** (1.12.2): `/pl/home` (the slug of the page assigned as Homepage) → 308 to `/pl` — one URL per page (canonical already pointed to the root; Search Console reported a duplicate). Turn off: `createPageRoute(…, { homeAlias: false })`. Manually (full file — when you need something `createNotFoundPage` does not have): ```tsx import React from 'react' import { RenderBlocks } from '@intecion/ipal-kit/rsc' import { LocaleView } from '@intecion/ipal-kit/client' import { i18nConfig } from '@/i18n.config' import { blockRegistry } from '@/blocks/registry' import { getConfiguredLocales, getNotFoundPage } from '@/lib/content' /** * 404 view. The editor picks which page plays the 404 role in * Site settings → System pages → "404 (Not Found)" — a dedicated page or the * homepage — or leaves it empty → the fallback below. * * not-found.tsx receives no params, and reading headers() here would turn the * SSG/ISR site dynamic ("Page changed from static to dynamic at runtime"). * So: render the 404 page for EVERY locale on the server (DB reads only — stays * static) and let pick the one from the URL (/en/... → en). * Next still answers HTTP 404. */ export default async function NotFound() { const locales = await getConfiguredLocales() const views = Object.fromEntries( await Promise.all( locales.map(async (locale) => { const page = (await getNotFoundPage(locale)) as { layout?: unknown[] } | null const view = page?.layout?.length ? ( ({ locale })} /> ) : null return [locale, view] as const }), ), ) // No 404 page assigned in any locale (or DB unreachable during build): // the project's own minimal view — style it, keep it text-free or panel-driven. if (Object.values(views).every((v) => v === null)) { return (

404

) } return } ``` > **Do NOT read `headers()` in `not-found.tsx`** (`LocaleView` since 1.8.2). `not-found.tsx` gets no > `params`, but `headers()` (e.g. `x-locale` from the proxy) turns an SSG/ISR page into a > dynamic one — Next 16 throws `Page changed from static to dynamic at runtime` > (AGENT.md §4.6). So the server renders the 404 page **for every language** > (DB reads only — the route stays static), and `` (the plugin's client > component) picks the version by the first URL segment (`usePathname`). > It also works with SSR — the HTML has the right language right away. The `[locale]` layout > (header, menu, footer) gets `params.locale` from the URL anyway. The HTTP status stays **404** (Next renders it after `notFound()`), the content comes from the admin panel in the right language. Cost: the 404 page's RSC payload holds versions for all languages — negligible for a 404 page. What the plugin does automatically with an assigned 404 page: | Place | Behavior | |---|---| | `resolveRoute` | visiting `/pl/strona-nie-znaleziona` directly → `null` → `notFound()` → a real 404 (no soft-404 / duplicate with status 200) | | sitemap | excluded by ID (the slug can be anything) | | `generateStaticParams` | skipped (it is not a separate URL) | | `getNotFoundPage` / `resolveNotFoundPage` | never throws — no database during the build = fallback | When 404 = the home page, none of the above hides the home page — it still works under `/{locale}` and is in the sitemap; on top of that its content shows under unknown URLs (with status 404). Without `createContentHelpers`: `resolveNotFoundPage({ payload, locale })` from `@intecion/ipal-kit`. Tip: tick **noindex** on a dedicated 404 page — then it also drops out of llms.txt and search. ## CRITICAL: generateStaticParams for [[...slug]] (SEO + head) Next treats a `[[...slug]]` route (optional catch-all) WITHOUT `generateStaticParams` as **dynamic** (`ƒ Dynamic`). In dynamic mode with React 19 the server sends an empty ``, and metadata streams at the end of `` — crawlers (Lighthouse, Screaming Frog) don't see `` in the head → SEO drops. **With `generateStaticParams` the route compiles as SSG (`●`)** → a synchronous, complete `` → SEO 100/100. This is the strongest fix for the metadata-in-head problem (stronger than ISR/htmlLimitedBots alone). The plugin provides a ready generateStaticParams through createContentHelpers: ```ts // lib/content.ts — add to the destructuring export const { getCachedPayload, getSettings, resolveRoute, generateStaticParams, // ← from the plugin sitemap, robots, } = createContentHelpers({ config, content: contentConfig, i18n: i18nConfig, baseUrl }) // app/(frontend)/[[...slug]]/page.tsx (or [locale]/[[...slug]]) export { generateStaticParams } from '@/lib/content' ``` The helper automatically: fetches **only the Pages collection** (`pagesSlug`), at most **1000 documents per language** (`limit: 1000`, no pagination — the rest render on demand); turns the home page into the root (`slug: []`); skips drafts, the page assigned as 404, and the slugs `404`, `500`, `error`, `not-found`; returns `{slug}[]` (single-language) or `{locale, slug}[]` (multi-language). It handles multi-level slugs (`a/b` → `['a','b']`) and localized ones (a string or a per-language map). **Entries of the `content` collections (`/pl/artykuly/moj-post`) and paginated archive pages are NOT generated** (`src/modules/frontend/createContentHelpers.ts` ~514) — they render on demand on the first visit. If entries must be SSG, add your own `generateStaticParams` that combines the helper's result with the entries. Database unavailable during the build (Docker/CI) → `[]` + a warning in the log, the build does not fail. Details: [frontend.md](./frontend.md#generatestaticparams--what-it-really-generates). **noindex pages ARE rendered** (not skipped as in the sitemap). A legal page (policy, cookies) with noindex must still display — the user comes from the footer, the crawler reads its ``. noindex controls INDEXING, not whether the page exists. Skipping it would force dynamic rendering (the same streaming problem we avoid). The helper does NOT filter `_status` in the query (`where`) — collections without drafts turned on have no such field and the query would throw. Drafts are filtered out in memory (safe for any collection). ## TRAP: await searchParams de-optimizes ISR In Next 15/16 `searchParams` is a Promise. Reading `const { page } = await searchParams` in a page component **de-optimizes ISR** — it forces dynamic rendering for that request (losing all the SSG/ISR gain + the metadata-in-body problem returns). - **Page WITHOUT pagination** → do NOT pass/read `searchParams` at all: ```ts export default async function Page({ params }) { // no searchParams const { locale, slug } = await params const route = await resolveRoute(locale, slug ?? []) // no page } ``` - **Page WITH pagination** (archive) → read searchParams, but deliberately (this route will be dynamic). Consider a separate route for the paginated archive, so regular pages stay SSG. Rule: `searchParams` only where you REALLY need it (pagination). Everywhere else skip it — otherwise you lose SSG and SEO. ## Turn off, override, extend - Turn off: omit the `pages` option — the System pages and Maintenance tabs disappear (and `content` stops working). - `roles` limits the set of role fields; field labels and descriptions are fixed (English and Polish, set by the plugin); to change them, override the field through `globalOverrides` (hooks.md). - You cannot add your own roles with the `pages` option — add extra SiteSettings fields with `siteSettingsFields` (the "More" tab, payload-helpers.md), but then call the helpers (`getSystemPagePath`, `getSystemLinks`) by hand: `getSystemPagePath({ page: settings.myRole, … })`, `getSystemLinks(locale, ['myRole'])`. - 404: `createNotFoundPage` (`load` / `blocks` / `fallback` / `blockProps`) or a fully custom `not-found.tsx` (above). - Catch-all page: `createPageRoute` with `render`, `onMissing`, `homeAlias: false` — or your own page on `resolveRoute`.