SEO

Hreflang Generator and Validator

Add language and regional page versions, check common hreflang mistakes, and generate implementation-ready annotations without uploading your URLs.

New to hreflang? Read the step-by-step beginner guide

01

Build the complete alternate set

Use only substantially equivalent language or regional versions of the same page.

Waiting for alternate pages

When supplied, the exact normalized URL should appear among the non-x-default entries.

Language: two- or three-letter primary code, optionally with a valid hyphen-separated subtag such as zh-Hans.

Region: optional two-letter country code. GB means the United Kingdom; it is not a language.

URL: an absolute HTTP or HTTPS page URL. Paths, queries, and fragments are preserved.

Label: optional working note shown only in this editor and never added to generated output.

x-default: optional fallback for unmatched users; only one row can use it.

Structure-only validation: Foxger validates URL and code structure only. It does not check whether submitted pages exist, are indexable, or return a successful HTTP status.

04

Validation summary

Add equivalent alternate pages, then generate the complete set.

05

Generated output

Choose one implementation format and maintain the same complete set consistently.

HTML alternate link tags

Usually the simplest method for ordinary HTML pages. Place the complete set in the document head.

0 characters

After generation

What should I do with this output?

Choose one format your website can maintain, install the complete set on the equivalent pages, and check the live implementation separately. The guide below explains each step from the beginning.

Start the beginner guide
Step-by-step guide

Learn hreflang from the beginning

This guide explains the idea, the form, the generated code, and the checks that still need human review. You do not need previous Search Engine Optimization (SEO) or coding knowledge.

Back to the generator
Beginner guide contents
Start here

Hreflang in one minute

Imagine a website has the same guide in English and Spanish. Both pages teach the same topic, but each one serves readers who use a different language.

Hreflang is a label that tells a search engine those pages are language alternatives. The search engine can use that relationship when deciding which version may suit a searcher.

Hreflang does not

  • translate a page;
  • redirect a visitor;
  • guarantee indexing, traffic, or rankings;
  • replace clear language navigation or a language selector.
Make the first decision

Do you need hreflang?

Ask whether the pages are language or regional versions of substantially the same page. A matching topic, design, or menu is not enough by itself.

Hreflang may be appropriate

  • The same article exists in English and Spanish.
  • The same product page serves English readers in the US and UK.
  • The same documentation page exists in Japanese and English.
  • Country-specific pages contain mostly equivalent information.
  • Equivalent pages are on different subdomains or domains.

Hreflang is probably not the answer

  • The site has only one language.
  • The pages discuss different topics or have different purposes.
  • One page is a summary and the other is a different article.
  • You want a tool to translate the page automatically.
  • You want to redirect visitors by country.
  • You only need to declare the language of one HTML page.
Prepare first

Before you use the generator

Collect these details before entering rows:

  • the full URL of every equivalent page;
  • the language used by each page;
  • an optional target region, only when the page is genuinely regional;
  • the URL of the current page;
  • a decision about whether an x-default fallback is useful;
  • a decision about where the generated code can be installed.
Correct: full URLhttps://example.com/guides/solar-system/
Incorrect: missing hostname/guides/solar-system/
Incorrect: missing protocolexample.com/guides/solar-system/
Read the form

Understand every field

Each field has one job. The page label is the only field that never appears in generated code.

Current page URL Optional

Enter the full address of the page you are working on. Foxger compares it with the non-x-default rows to check for an exact self-reference. Foxger does not visit the URL. Without this value, it can offer guidance but cannot confirm that the current page is in the set.

Language code Required

Identify the page language. Common values include en for English,es for Spanish, de for German, fr for French, and ja for Japanese. A language code is not a country code.

Region code Optional

Narrow a language version to an intended region. Examples include US,GB, MX, and BR. Use it because the content targets that audience, not because the website owner lives there.

Alternate page URL Required

Enter the complete address of that page, starting with https:// orhttp://. Aim at the final preferred URL. Foxger checks its structure but does not open the page, follow redirects, or test its status.

Page label Optional, tool only

Add a friendly working note such as “English page” or “Spanish page.” It helps you manage rows inside Foxger and is not included in HTML, HTTP, or XML output.

Mark as x-default Optional

Use this for one fallback page, such as a language chooser or global page. The row must not also contain a language or region. x-default is optional, and English should not be selected automatically as the fallback.

XML sitemap output type Shown in the XML output tab

Choose XML fragment when adding the generated blocks to an existing sitemap whose parent urlset includes the XHTML namespace. ChooseFull minimal sitemap document when you need a small standalone sitemap file containing this set. Your site may still need to connect that file to its sitemap setup.

Row and example controls

  • Add alternate creates another empty page row.
  • Duplicate copies a row so you can edit a similar version.
  • Move up and Move down change the order used in generated output.
  • Remove deletes that row. Foxger keeps at least one usable row area.
  • Load example fills a separate sample set for practice.
  • Clear all removes the entered rows and generated output from the page.

Small x-default example

English page → en

Spanish page → es

Language chooser → x-default

Build the value

How a language tag is built

A basic tag starts with the language. Add a region only when it describes the page.

enlanguage
GBoptional region

The hyphen is the separator. Foxger displays the language in lowercase and a two-letter region in uppercase. BCP 47 comparisons are case-insensitive, so this capitalization is a clear convention rather than a change in meaning.

Incorrect separatoren_US
Correcten-US
Incorrect for UK EnglishUK
Correcten-GB
IncorrectEnglish
Correcten

en means general English. en-GB means English content intended for the United Kingdom. It does not mean “British language.”

Advanced note: scripts and broader language tags

BCP 47 can include a script and other registered subtags. For example,zh-Hans identifies Chinese written in the Simplified script, whilezh-Hant identifies Chinese written in the Traditional script.

A script and a region describe different choices. Foxger does not guess betweenzh-CN, zh-TW, zh-Hans, or zh-Hant. Its check is structural; it does not confirm every subtag in the IANA registry or promise that every structurally valid BCP 47 tag is supported by every search engine.

One example from start to finish

Complete beginner example

A fictional educational site has the same “Solar System Guide” in English, Spanish, and German. It also has a language selector. These four URLs stay the same throughout this guide.

English
https://example.com/guides/solar-system/
Spanish
https://example.com/es/guias/sistema-solar/
German
https://example.com/de/ratgeber/sonnensystem/
Language selector
https://example.com/languages/
  1. Enter the current pagehttps://example.com/guides/solar-system/
  2. Add EnglishLanguage en · Region blank · English URL
  3. Add SpanishLanguage es · Region blank · Spanish URL
  4. Add GermanLanguage de · Region blank · German URL
  5. Add x-defaultSelect x-default · Language and region blank · Language-selector URL
  6. GenerateExpect no blocking errors, an English self-reference, four alternate values, and output in HTML, HTTP-header, and XML-sitemap formats.
Use the tool with confidence

Follow along in 12 steps

Each step tells you what to do, why it matters, and one mistake to avoid.

  1. Decide which pages belong together

    What to do: Choose pages that give readers substantially equivalent information.

    Why: Hreflang describes alternate versions of one page, not a group of loosely related pages.

    Example: Group the English, Spanish, and German Solar System guides.

    Avoid: Do not connect an English planet guide to a Spanish astronomy news page.

  2. Copy the full current-page URL

    What to do: Paste the address of the page you are working on into Current page URL.

    Why: Foxger can then check whether that page appears in its own alternate set.

    Example: https://example.com/guides/solar-system/

    Avoid: Do not enter only /guides/solar-system/.

  3. Add the first language version

    What to do: Enter its language code and full URL in the first row.

    Why: Each row connects one language or regional version to the group.

    Example: Language en with the English guide URL.

    Avoid: Do not enter a country code where the language belongs.

  4. Add the second language version

    What to do: Use the next row for the second equivalent page.

    Why: A useful hreflang set normally has at least two localized versions.

    Example: Language es with the Spanish guide URL.

    Avoid: Do not reuse en for the Spanish page.

  5. Add more versions when needed

    What to do: Select Add alternate for each additional equivalent page.

    Why: The generated set should describe the whole language group you plan to implement.

    Example: Add de for the German guide.

    Avoid: Do not add an empty row merely to make the list look complete.

  6. Add an optional region

    What to do: Use Region only when a page intentionally serves a regional audience.

    Why: A region narrows a language version; it does not identify the language by itself.

    Example: Language en plus Region GB becomes en-GB.

    Avoid: Do not add GB only because the site owner lives in the United Kingdom.

  7. Add x-default only when useful

    What to do: Mark one fallback or language-selector row as x-default, if your site has one.

    Why: It gives search engines a fallback for users who do not match the listed choices.

    Example: Use https://example.com/languages/ for the language chooser.

    Avoid: Do not assume the English page must be x-default.

  8. Review validation messages

    What to do: Read the errors, warnings, and information in the validation summary.

    Why: The messages separate blocking input problems from choices that only need review.

    Example: A mixed-hostname warning can be acceptable when the domains are intentional.

    Avoid: Do not treat every warning as proof that the set is invalid.

  9. Fix blocking errors

    What to do: Correct every error before using the output.

    Why: Errors mean Foxger cannot create a reliable annotation set from the entered data.

    Example: Replace en_US with language en and region US.

    Avoid: Do not copy output while a row has an invalid or missing URL.

  10. Generate the annotation set

    What to do: Select Generate annotations after the rows are ready.

    Why: Foxger normalizes the values and creates each supported output format.

    Example: The Solar System example produces en, es, de, and x-default.

    Avoid: Do not expect Generate to visit or test the pages.

  11. Choose one output method

    What to do: Pick HTML, HTTP Link header, or XML sitemap output for your implementation.

    Why: A method your site can maintain is better than several inconsistent copies.

    Example: Most beginners editing ordinary webpages can start with HTML tags.

    Avoid: Do not assume that adding all three methods improves rankings.

  12. Install the complete set

    What to do: Place the same complete group on each equivalent page using your chosen method.

    Why: Each page should normally name itself and return the links from its alternates.

    Example: English, Spanish, and German pages each list all four generated values.

    Avoid: Do not install the set only on the English page.

Back to the generator

Read the summary

Errors, warnings, and information mean different things

Error

An error blocks reliable output and should be fixed.

Examples: invalid URL, missing language, duplicate hreflang value, or more than one x-default.

Warning

A warning allows output but asks you to review a possible risk or intentional choice.

Examples: mixed hostnames, missing self-reference, no x-default, or one URL used for several values.

Information

Information explains a choice or a check Foxger cannot complete.

For example, without a current-page URL, Foxger gives general self-reference guidance.

Not every warning means the set is invalid. x-default is optional. Different domains can be valid. A language-only fallback is not mandatory for every regional strategy. Foxger checks entered structure, not live pages.

Create the set

Generate your code

  1. Review every row and correct blocking errors.
  2. Select Generate annotations.
  3. Read the validation summary before copying anything.
  4. Open the HTML, HTTP header, or XML output tab.
  5. Copy the output, or download it with Foxger’s fixed safe filename.

Generation happens in your browser. Foxger does not visit the destinations, check whether they exist, or add the output to your website.

Choose a method

Choose an output format

Google supports HTML tags, HTTP Link headers, and XML sitemap annotations. Choose the method that your website can implement correctly and keep updated.

Often a direct first implementation

HTML tags

Usually the most direct choice for ordinary HTML webpages. Add the lines inside the page’s<head>, the part of an HTML document that holds page metadata and settings. Every equivalent page should normally contain the complete set.

<link rel="alternate" hreflang="en" href="https://example.com/guides/solar-system/" />
<link rel="alternate" hreflang="es" href="https://example.com/es/guias/sistema-solar/" />
<link rel="alternate" hreflang="de" href="https://example.com/de/ratgeber/sonnensystem/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/languages/" />
Useful for some non-HTML files

HTTP Link header

The web server sends this metadata with the resource. It can be useful for files such as PDFs, but it usually requires server or hosting configuration and is not the most direct first choice for an ordinary webpage.

Link: <https://example.com/guides/solar-system/>; rel="alternate"; hreflang="en", …
Useful for centrally managed or larger sites

XML sitemap

A sitemap is a structured file that lists site URLs for search engines. Each localized page block normally contains the complete alternate set. The parent sitemap needs the XHTML namespace.

<url>
  <loc>https://example.com/guides/solar-system/</loc>
  <xhtml:link rel="alternate" hreflang="en" href="https://example.com/guides/solar-system/" />
  <xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/guias/sistema-solar/" />
  <xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/ratgeber/sonnensystem/" />
  <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/languages/" />
</url>

Google treats the supported methods as equivalent. Maintaining more than one gives you more copies to keep in sync. One consistent method is often clearer unless there is a practical reason to use another.

Put the code in the right place

Install the HTML output

The generated <link> lines belong inside the document’s <head>.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Solar System Guide</title>

    <!-- Paste the generated hreflang tags here -->
  </head>
  <body>
    <h1>Solar System Guide</h1>
  </body>
</html>
  • Do not paste the tags into the visible article text.
  • Do not paste them into a normal page editor unless it supports custom head code.
  • Website builders and content-management systems use different installation methods.
  • You may need an internationalization setting, SEO setting, template, trusted plugin, or developer.
Include the page itself

Self-reference and return links

On the English page, the generated set still includes the English line. The page includes itself in the language group so the complete set is clear.

<link rel="alternate" hreflang="en" href="https://example.com/guides/solar-system/" />

English page lists

English · Spanish · German · x-default

Spanish page lists

English · Spanish · German · x-default

German page lists

English · Spanish · German · x-default

Two tools, two jobs

Hreflang and canonical tags

A canonical tells search engines which URL is the preferred version among duplicate or near-duplicate URLs. Hreflang tells them which localized versions belong together. The two signals are related, but they are not interchangeable.

Canonical: Which URL is the preferred copy of this page?

Hreflang: Which language or regional version may suit this user?

A common pattern for fully localized pages is:

English page canonical → English page
Spanish page canonical → Spanish page
German page canonical → German page

Then all three pages participate in the same hreflang set.

Review before publishing

Check your work

First review the data in Foxger. Then inspect the live implementation separately.

Check the entered data

  • Every page is an equivalent version.
  • Every URL is complete.
  • Language values are correct.
  • Optional regions are intentional.
  • No language tag contains an underscore.
  • No language-region value is duplicated.
  • There is no more than one x-default.
  • The current page appears in the set.

Check the installed output

  • The complete set is installed.
  • Every equivalent page returns the corresponding links.
  • URLs point to final preferred pages.
  • Pages can be crawled and return successful responses.
  • Canonical tags support the localized pages.
  • The code is in a supported location.
  • The XHTML namespace exists in sitemap output.
Pause before publishing

Common mistakes

Items marked “Manual check” describe live-site details that Foxger cannot test.

  1. Connecting unrelated pagesManual check

    Only connect pages that provide substantially equivalent content.

  2. Using relative URLs

    Include the complete address, starting with https:// or http://.

  3. Leaving out the current page

    Each localized page should generally include itself in the set.

  4. Missing reciprocal annotationsManual check

    Each equivalent page should normally point back to the other pages.

  5. Writing en_US

    Use the BCP 47 hyphen separator: en-US.

  6. Using a country without a language

    GB is a region. English for the UK is en-GB.

  7. Adding an unnecessary regionManual check

    Use a region only when the page is intentionally regional.

  8. Assuming English is x-defaultManual check

    Choose a fallback deliberately; x-default is optional.

  9. Creating several x-default entries

    One alternate set can contain no more than one x-default value.

  10. Canonicalizing every translation to EnglishManual check

    Localized pages commonly use a same-language or self canonical. Review the site’s needs.

  11. Mixing final and redirected URLsManual check

    Manual check: use each final preferred page URL where possible.

  12. Using blocked or non-indexable pagesManual check

    Manual check: Foxger cannot inspect crawling or indexing settings.

  13. Adding only one directionManual check

    A link from English to Spanish should normally be returned from Spanish to English.

  14. Omitting the XHTML namespaceManual check

    XML sitemap hreflang needs the xhtml namespace on the parent urlset.

  15. Connecting non-equivalent pagesManual check

    A shared layout or topic is not enough; the page purpose and main information should match.

  16. Expecting hreflang to translate content

    Hreflang labels relationships. It does not create a translation.

  17. Expecting guaranteed rankings

    Hreflang is a signal to search engines, not a promise of indexing, traffic, or position.

Solve a message calmly

Troubleshooting

Open the problem that matches what you see.

“Foxger says my URL is invalid”

Check whether it starts with https:// or http://, contains an accidental space, is incomplete, or uses an unsupported protocol.

“Foxger says I have a duplicate hreflang value”

Only one URL should be assigned to a particular value, such as es, within one alternate set. Remove the duplicate or correct the language or region.

“Foxger says the current page is missing”

Add the current page as its own non-x-default language version. Make sure its full URL exactly matches the value in Current page URL.

“My pages use different domains”

This can be valid. Confirm that the pages are equivalent and that every domain implements the complete reciprocal set. Foxger warns so you review the choice.

“I do not have a language-selector page”

Leave out x-default. It is optional, not a requirement.

“I use only English and Spanish”

Two equivalent versions can form a set. Add en for the English URL and es for the Spanish URL, then install both annotations on both pages.

“I have English for the US and UK”

Use en-US and en-GB when the pages genuinely target those regions. A general en fallback may help some content strategies, but it is not universally mandatory.

“My website builder does not let me edit the head”

Check its SEO, internationalization, template, or sitemap settings. A trusted platform extension or developer may be needed. Do not paste tags into visible page text.

Look up a word

Glossary

Alternate page
A language or regional version of another page with substantially equivalent content.
Canonical URL
The URL a page identifies as the preferred version among duplicate or near-duplicate URLs.
Country or region code
An optional subtag that narrows a language version to a region, such as GB in en-GB.
Fully qualified URL
A complete web address that includes the protocol and hostname, such as https://example.com/page/.
HTML
HyperText Markup Language is the code that gives a webpage its structure.
HTTP header
Information a web server sends with a resource before the browser receives its content.
Hreflang
An annotation that identifies alternate language or regional versions of a page.
Indexing
The process by which a search engine stores and organizes information about a page for possible search results.
Language code
A short registered subtag that identifies a language, such as en for English or es for Spanish.
Localized page
A page adapted for a language or regional audience. Translation may be part of that work.
Reciprocal link
A return annotation from one alternate page back to the page that named it.
Redirect
A server or browser instruction that sends a visitor from one URL to another. Hreflang is not a redirect.
Search engine
A service that discovers, organizes, and helps people find information on the web.
Self-reference
An annotation in which a page includes its own URL as one member of the alternate set.
Sitemap
A file that lists site URLs and can include extra information for search engines.
URL
Uniform Resource Locator: the address used to find a page or resource on the web.
x-default
An optional fallback hreflang value for users who do not match another listed language or region.
XML
Extensible Markup Language is a text format used to organize structured data, including sitemaps.
Optional practice

Try a small language-tag exercise

Open the practice activity

A fictional guide has these versions:

  • General English: https://example.com/learn/stars/
  • US English: https://example.com/us/learn/stars/
  • Spanish: https://example.com/es/aprender/estrellas/

Which hreflang values should you enter? Should a separate language selector be marked en or x-default?

Show the answer

Use en, en-US, and es.

A separate language selector can use x-default because it is the fallback, not the English page. x-default remains optional.

One last review

Ready to generate?

  • My pages are equivalent versions.
  • I copied each full URL.
  • I chose the correct language.
  • I added a region only when needed.
  • I used hyphens instead of underscores.
  • I included the current page.
  • I used no more than one x-default.
  • I reviewed all errors and warnings.
  • I chose one suitable output format.
  • I understand that the complete set belongs on each equivalent page.
  • I will check canonicals, redirects, and indexability separately.
Back to the Hreflang Generator
FAQ

Hreflang questions

Does Foxger check whether my URLs are live?

No. Foxger validates URL structure locally but does not visit submitted URLs, check HTTP status codes, inspect redirects, or confirm indexability.

Is x-default required?

No. x-default is optional. It is commonly used for a language selector, global page, or fallback for users who do not match another language or region.

Should every hreflang page reference itself?

Pages should generally include a self-referencing annotation as part of the complete alternate set. Foxger can compare an optional current page URL with the set, but it cannot inspect the live page.

Can different hreflang URLs use different domains?

Yes, different domains can be valid. Foxger shows a cautious mixed-hostname warning so you can review the set, not because different domains are automatically wrong.

Should translated pages use the same canonical URL?

Localized pages usually use self-referencing canonicals. Hreflang does not replace canonical tags, and canonicalizing every translation to one language page can conflict with localization goals.

Can I use both language and country codes?

Yes. A language value such as en means general English, while en-GB means English content intended for the United Kingdom. A country code does not identify a language by itself.

Should I add hreflang in HTML and a sitemap?

Use the method your team can implement consistently. Google treats the supported methods as equivalent, while maintaining duplicate implementations can add avoidable complexity.

Is en_US a valid hreflang value?

No. Hreflang values use hyphens rather than underscores. Enter en as the language and US as the optional region to generate en-US.

Optional support

Help keep Foxger useful

Foxger tools are free, private, and built without display ads. Optional support helps keep them maintained, tested, and documented.

Support Foxger