Configuration

Localized alternate metadata

Use alternates.languages to link equivalent, published regional or language versions. Each variant should list itself and the other variants, using absolute URLs. The example assumes genuinely distinct English regional editions at both paths; if only one edition exists, omit the regional alternate set. No Persian page is generated or advertised. This is metadata construction, not evidence that pages are indexed. Source: https://developers.google.com/search/docs/specialty/international/localized-versions. Documentation-reviewed illustrative draft; installed declarations and runtime not verified.

Formal Syntax & Structure

nextjs syntaxnextjs
alternates: { canonical: string, languages: Record<string,string> }

Working Example

Example Snippetnextjs
// Shared helper used by each regional page; both variants must be published.import type {Metadata} from 'next';const urls={'en-US':'https://books.example/en-us/catalog/river-walks','en-GB':'https://books.example/en-gb/catalog/river-walks'};export function regionalMetadata(locale:keyof typeof urls):Metadata { if(!Object.hasOwn(urls,locale)) throw new TypeError('Unsupported locale'); return {alternates:{canonical:urls[locale],languages:{...urls}}};}
Next.js Reference