Symptom
On https://catholicdigitalcommons.org/it/governance, the four section cards link to URLs with a doubled locale, e.g.:
- "Governanza del Progetto" →
https://catholicdigitalcommons.org/it/it/governance-2/governanza-del-progetto
(the /it/it/ is wrong; the correct URL would be /it/governance-2/governanza-del-progetto)
Root cause
components/sections/GovernanceTOC.tsx:37 does:
<Link key={page.slug} href={page.uri} ... />
page.uri comes from getChildPages → GraphQL pages { nodes { uri } } (lib/wordpress/queries.ts:403). With Polylang in directory mode, this URI already includes the language prefix (/it/governance-2/governanza-del-progetto). The <Link> from @/src/i18n/navigation (which wraps next-intl's navigation with localePrefix: 'as-needed' from src/i18n/routing.ts:7) then prepends the locale again.
Suggested fix
Don't trust Polylang's uri field in headless mode — it describes how the URL would look on a Polylang-rendered front-end, not on Next.js. Use the slug chain (or the leaf slug plus the parent context) and let next-intl add the locale prefix exactly once.
Concretely:
- Drop
uri from GET_CHILD_PAGES in lib/wordpress/queries.ts.
- Have the catch-all page (
app/[lang]/[[...slug]]/page.tsx) compose the path from its own URL segments + each child's slug, e.g. [...currentSlug, child.slug].join('/').
- Pass that to
<Link href=...>.
Related
This is the same misuse pattern as the sitemap bug (separate issue) and is part of the broader "translated slugs aren't actually consumed" gap (Header navigation issue, also separate).
Symptom
On
https://catholicdigitalcommons.org/it/governance, the four section cards link to URLs with a doubled locale, e.g.:https://catholicdigitalcommons.org/it/it/governance-2/governanza-del-progetto(the
/it/it/is wrong; the correct URL would be/it/governance-2/governanza-del-progetto)Root cause
components/sections/GovernanceTOC.tsx:37does:page.uricomes fromgetChildPages→ GraphQLpages { nodes { uri } }(lib/wordpress/queries.ts:403). With Polylang in directory mode, this URI already includes the language prefix (/it/governance-2/governanza-del-progetto). The<Link>from@/src/i18n/navigation(which wrapsnext-intl's navigation withlocalePrefix: 'as-needed'fromsrc/i18n/routing.ts:7) then prepends the locale again.Suggested fix
Don't trust Polylang's
urifield in headless mode — it describes how the URL would look on a Polylang-rendered front-end, not on Next.js. Use the slug chain (or the leafslugplus the parent context) and let next-intl add the locale prefix exactly once.Concretely:
urifromGET_CHILD_PAGESinlib/wordpress/queries.ts.app/[lang]/[[...slug]]/page.tsx) compose the path from its own URL segments + each child'sslug, e.g.[...currentSlug, child.slug].join('/').<Link href=...>.Related
This is the same misuse pattern as the sitemap bug (separate issue) and is part of the broader "translated slugs aren't actually consumed" gap (Header navigation issue, also separate).