Skip to content

hreflang for translated pages

Tell search engines which language version of each page to show, with correct, reciprocal hreflang.

  • Free, no sign-up
  • 45 to 90 minutes with an agent
  • By Devvrat Hans
  • Version 1.0, updated Oct 26, 2026

1Your site and stack

Optional. The prompt adapts as you type; leave a field blank and the agent works it out.

2Copy it into your agent

hreflang.md62 lines, about 820 tokens

Paste into any coding agent: Claude Code, Cursor, Codex, Copilot, Windsurf or Cline.

# hreflang for translated pages

If the production site has pages in more than one language or for more than one region, search engines need to know which version to show to whom. Wrong hreflang shows people the wrong language or drops pages. Set it up from one helper so every page lists all its versions correctly.

Site: not given. Find the production URL in the project config, or ask me.

## Ground rules

1. Read before you write. Explore the parts of the codebase this job touches and tell me what is already in place.
2. Plan, then stop. Give me a numbered plan: what you will change, in which files, and why. Wait for my approval before editing anything.
3. Fix things at their source (the shared layout, the config, the generator), not with one-off patches page by page.
4. Keep the project's conventions: its framework APIs, file layout, naming and code style. Add no new dependency without asking.
5. Where something is already done well, say so and leave it alone.

## You will not

- Edit `.env` files, secrets or API keys, or print their values.
- Deploy, push, merge or publish anything.
- Delete data, or run migrations or scripts against a production database.
- Add tracking, third-party scripts or links to any site I did not ask for.
- Change copy, design or behaviour that this job does not need.
- Machine-translate content.
- Change URL structures without a redirect plan.

## Your stack

- Framework: Work out the framework, router and build output from the project files (package.json, lockfiles, framework config) before planning, and say which you found.
- Host: Work out where the site is hosted from the config files (vercel.json, netlify.toml, wrangler config, Dockerfile, fly.toml) and say which you found.

## Steps

### 1. Map the versions

List the languages and regions the site serves, how URLs are structured (subdirectories, subdomains, separate domains, query parameters) and which pages exist in which versions. Flag pages that exist in only some languages.

### 2. Generate hreflang from one helper

For each page, output a `<link rel="alternate" hreflang="...">` for every version that exists, including the page itself, using valid codes (language like `en`, `de`, or language-region like `en-GB`, `pt-BR`). Add `x-default` for the version shown when no language matches. All URLs absolute and canonical.

### 3. Keep it reciprocal and consistent

Every version must list every other version back. Each version's canonical points at itself, never at another language. Pages that are not translated list only the versions that exist.

### 4. Do not redirect by language

Do not force-redirect visitors or crawlers by browser language or IP; offer a language switcher instead, so crawlers can reach every version.

## Done means

- [ ] Every translated page lists all its versions, including itself, with valid codes and x-default.
- [ ] hreflang links are reciprocal across versions.
- [ ] Each version is self-canonical.
- [ ] Visitors are not force-redirected by language; a switcher lets them choose.

## Report back

When you finish, give me:

- what you changed, file by file;
- anything you skipped, and why;
- anything I must do by hand (DNS records, dashboards, accounts, deploys);
- how to check each change on the live site.

One-line version

For agents that can read a URL. It fetches this prompt with your settings applied.

Read https://abacklaunch.com/prompts/hreflang.md and follow it for this project.

3Check the result

When the changes are live, run these free checks. Add your site URL above and each one opens already running on it.

This prompt will not

  • Edit .env files, secrets or API keys, or print their values.
  • Deploy, push, merge or publish anything.
  • Delete data, or run migrations or scripts against a production database.
  • Add tracking, third-party scripts or links to any site I did not ask for.
  • Change copy, design or behaviour that this job does not need.
  • Machine-translate content.
  • Change URL structures without a redirect plan.

It reads your code first, shows you a plan, and waits for your approval before it changes anything.

What you get

  • A map of your language versions
  • Correct, reciprocal hreflang from one helper
  • Self-canonical versions and a crawlable language switcher

How to use this prompt

  1. 1

    Describe your stack

    Add your site, framework and host. The prompt adapts; blank fields are left for the agent to work out.

  2. 2

    Paste it into your agent

    Open your project in Claude Code, Cursor, Codex, Copilot, Windsurf or Cline, and paste the prompt or the one-line version.

  3. 3

    Approve the plan

    The agent reads your code, shows you a plan with the files it will touch, and waits. Change anything you disagree with.

  4. 4

    Check the result

    When the changes are live, run the free checks below on your site to confirm each fix.

What the agent does

If the production site has pages in more than one language or for more than one region, search engines need to know which version to show to whom. Wrong hreflang shows people the wrong language or drops pages. Set it up from one helper so every page lists all its versions correctly.

  1. 1. Map the versions

    List the languages and regions the site serves, how URLs are structured (subdirectories, subdomains, separate domains, query parameters) and which pages exist in which versions. Flag pages that exist in only some languages.

  2. 2. Generate hreflang from one helper

    For each page, output a <link rel="alternate" hreflang="..."> for every version that exists, including the page itself, using valid codes (language like en, de, or language-region like en-GB, pt-BR). Add x-default for the version shown when no language matches. All URLs absolute and canonical.

  3. 3. Keep it reciprocal and consistent

    Every version must list every other version back. Each version's canonical points at itself, never at another language. Pages that are not translated list only the versions that exist.

  4. 4. Do not redirect by language

    Do not force-redirect visitors or crawlers by browser language or IP; offer a language switcher instead, so crawlers can reach every version.

Done means

  • Every translated page lists all its versions, including itself, with valid codes and x-default.
  • hreflang links are reciprocal across versions.
  • Each version is self-canonical.
  • Visitors are not force-redirected by language; a switcher lets them choose.

Questions

Do I need hreflang for one language?

No. hreflang is only for sites with versions in several languages or for several regions.

Should translated pages be canonical to the English page?

No. Each language version should be canonical to itself; pointing them all at one language tells search engines to drop the others.

Can I redirect visitors by browser language?

Suggesting a language is fine; forcing a redirect stops crawlers and travellers from reaching the other versions.

Does this prompt add links to Aback Launch to my site?

No. Nothing in the prompt mentions Aback Launch or asks your agent to link to us. The only exception is an optional badge step, which stays off unless you tick it. Some prompt libraries slip their own link into your codebase by default; we think that should always be your choice.

Which coding agents does it work with?

Claude Code, Cursor, Codex, GitHub Copilot, Windsurf, Cline, and any agent that can read your project and edit files. You can copy it as a plain prompt, save it as a Claude Code skill or a Cursor rule, or add it to AGENTS.md.

Is it safe to run on my real codebase?

The prompt makes the agent read first, show a plan and wait for your approval, and it forbids touching secrets, deploying and deleting data. Still review the changes and run your tests before you deploy, as with any change.

Changelog

  • v1.0First version.

Launch your startup on Aback Launch

Get a launch page that search engines and AI assistants can read, a place in the weekly launch list, and a review by a real person. Free to join.