I18n Locale Routing

i18n locale routing setup

A battle-tested blueprint for deterministic multi-language routing in Next.js App Router and Astro, where the URL path is the single source of truth for locale. It generates reciprocal hreflang, keeps SSG and edge caches accurate, and hard-blocks the exact configuration combination that silently collapses Search Console indexing.

$15 one-time
Add to a kit →

Prices include 20% VAT. · Forged on real agency work · one-time, no lock-in

  • Type Skill
  • Category Development
  • Delivery Email · instant
  • License One-time
Run preview
forgehouse, i18n-locale-routing

Inside the run · no black box

See the actual work before you buy it.

Three config flags once took a production site out of Google's index together. That guard runs before anything else, then routing locks to URL-as-truth and ships with reciprocal hreflang verified by live commands.

  1. Runs the TRAP-3 triple-combo guard first: greps the codebase for force-static, localeDetection:false and localeCookie:false at the same time. If all three match, the build fails on the spot, because that exact combination took a production site's GSC indexing down.
  2. Locks the routing config to URL-as-single-source-of-truth: a locale whitelist, localePrefix 'always' so the default locale is never URL-less, localeCookie false for cookie-free Edge-cache-friendly architecture, localeDetection true only as a first-visit Accept-Language fallback.
  3. Hardens the middleware with two validation layers: a host whitelist against open redirects, then a locale regex whitelist that sends invalid locale paths to an x-default 308 redirect instead of a 404.
  4. Applies the code-sharing pattern: one route file per page, generateStaticParams flattens locales x slugs into a cartesian build, so eight languages cost the maintenance of one.
  5. Generates reciprocal hreflang in generateMetadata: every locale page lists every other locale plus itself plus x-default, because Google logs one-way hreflang as ignored.
  6. Verifies with live commands: curl piped to a hreflang grep must return locales count plus one, build logs must show the N x M page count, and GSC gets a separate sitemap per locale to monitor indexing parity.
Use cases · what happens when you plug it in

One power source. 6 lines out.

i18n-locale-routing · core

core active · 6 lines

  1. Standing up a 2+ language site architecture in Next.js or Astro

    ✓ standing up a 2+ language
  2. Fixing missing or one-way hreflang causing 'duplicate, alternates not selected' in Search Console

    ✓ fixing missing or one-way
  3. Stopping stale cache that renders the wrong language after a locale switch

    ✓ stopping stale cache that
  4. Recovering from a force-static + detection-off + cookie-off crash that drops pages to 'crawled, not indexed'

    ✓ recovering from a force-…
  5. Spreading one route file across many locales automatically for programmatic SEO

    ✓ spreading one route file
  6. Building cookie-less locale detection for privacy compliance

    ✓ building cookie-less loc…
Benefits · what you walk away with

Yours to keep.

Drag time forward. Watch what stays.

Forever

That's what owning means.

The rented stack

ai writing tool: subscription

expired · access lost

analytics suite: subscription

expired · access lost

design platform: subscription

expired · access lost

(nothing left)

Your forge

  1. Avoid the silent indexing collapse that can take a month to recover from

    license: perpetual
  2. Ship eight languages with the maintenance cost of one through shared route files

    license: perpetual
  3. Keep edge cache hit rates high and locale switches under a fraction of a second

    license: perpetual
  4. Win correct international ranking with reciprocal hreflang and x-default fallback Google trusts

    license: perpetual

subscriptions expire · deeds don't

What's included · the full manifest

Everything in the box.

Pick a piece up. Watch it work.

Drop-in next-intl middleware and routing config with always-prefix locale paths

part 01 of 06 · in the box

6 parts · one working system · ships instantly by email

From the field · a real case

This wasn’t written at a desk.

2026-04-27 · The problem

The fix

The result

Who it's for

This wasn't forged for everyone.

  • Not for you if you'd rather rent a tool than own one.
  • Not for you if you want someone else to run your stack.
  • Not for you if you're happy guessing.
Still here? Good.

Front-end and SEO engineers building or repairing multi-locale Next.js and Astro sites where international indexing and cache correctness matter.

then this was forged for you.

Works with

Universal by design: these run in any AI. Delivered in the open Agent Skills + MCP format (native in Claude); ChatGPT, Gemini, Cursor and Copilot adapt the same files their own way.

  • Claude Native format
  • ChatGPT Adapts via open standards
  • Gemini Adapts via open standards
  • Cursor Adapts via open standards
  • Copilot Adapts via open standards
Questions · still in the air

Catch what's on your mind.

the air is clear. nothing between you and the forge.
catch a spark: the forge will answer

  1. We're on Astro, not Next.js. Does this still apply?

    Yes. You get the next-intl middleware and routing config for Next.js App Router, and a separate Astro hybrid-output i18n setup with fallback chains and directory format. Both follow the same principle: the URL path is the single source of truth for locale.

  2. What is the silent indexing collapse it mentions, and how does this prevent it?

    It's a specific configuration combination, force-static plus detection off plus cookie off, that drops pages to crawled-but-not-indexed and can take a month to recover from. The package includes a build-time guard that detects that combo and fails the build before it ever reaches production.

  3. Does it translate my content too?

    No. This is the routing, reciprocal hreflang, and cache-correctness layer. Your translations come from your own workflow; the blueprint makes sure each one is served at the right URL, in the right language, with hreflang Google trusts.

  4. How is it delivered?

    By email right after purchase: ready to run, downloaded instantly, no setup wait.

  5. One-time or subscription?

    A one-time purchase; no subscription or hidden fees. VAT (20%) is included.

  6. Can I get a refund?

    As a digital product, it can’t be refunded once downloaded. That’s why we show exactly what’s inside and who it’s for, right here.