With your agent / One address per language

Make each language version findable

“The German pages exist, but searches in Germany show the English ones.”

For sites that already speak more than one language and want search engines and agents to reach the right version of each page.

Prompt Replace the part in brackets, then paste it into your agent
Make each language version of this site findable:
- one address per language ([/en/, /de/]), never only a cookie or
  the browser's language
- <html lang> set to the language of the page
- <link rel="alternate" hreflang> to every language version of the page,
  and hreflang="x-default" to the default language
- a sitemap that lists every language version of every page
- the <title> and meta description from the translation files
At the end, show me the <head> of one page in each language.

What your agent does

  1. Gives each language its own address (/en/, /de/), never only a cookie or the browser's language.
  2. Sets <html lang> to the language of the page.
  3. Adds <link rel="alternate" hreflang> to every language version of the page, and x-default to the default language.
  4. Writes a sitemap that lists every language version of every page.
  5. Takes the <title> and meta description from the translation files.
  6. Shows you the <head> of one page in each language.

Where it goes in your framework

  • Astro: a page file under src/pages/[lang]/ gives each language its address (Astro's i18n routing adds the redirect and the URL helpers); the layout writes the hreflang links, as in Getting started with Astro.
  • Next: next-i18next puts the language in the path; generateMetadata returns alternates.languages with getLocalizedPath for each language, as in Translated paths of the next-i18next docs.
  • A single-page app that keeps the language only in the browser has one address for all languages. Give each language its own path first (a router with /:lng/), then the rest of the prompt applies.

Before it goes live

  • Open one page in each language: the address, <html lang>, the title and the texts change together.
  • Each hreflang link points to a page that exists and links back.