Hreflang Tag Generator
Generate hreflang alternate tags from locale and URL rows with self-reference, x-default, duplicate-locale, absolute-URL, and fallback checks before launch.Hreflang Tag Generator
- {{ issue }}
{{ headTags || emptyHeadMessage }}
| Locale | URL | Label | Status | Copy |
|---|---|---|---|---|
| No alternate rows are ready yet. | ||||
| {{ row.locale }} | {{ row.url }} | {{ row.label || '—' }} | {{ row.status }} {{ row.note }} | |
| Check | Status | Detail | Copy |
|---|---|---|---|
| {{ row.check }} | {{ row.status }} | {{ row.detail }} |
Hreflang annotations tell search engines which pages are alternate language or regional versions of the same content. They are not translation tools, redirects, or canonical tags. Their job is to help a search result point a visitor toward the version that best matches a language or region setting.
A good hreflang cluster is reciprocal. Each localized page should list itself and the same set of alternates, using fully qualified URLs and stable locale codes. A missing self-reference, a duplicate locale, or a regional group without a broader language fallback can make the cluster harder to review before launch.
Hreflang is most useful for pages that are meaningfully equivalent, such as the same product, help article, landing page, or legal page adapted for different languages or regions. It does not decide whether content is translated well, whether a page is indexable, or whether canonical tags agree with the alternate set.
The safest launch pattern is to build one clean cluster, copy it into the head of every matching page, and then test the live pages for return links, indexability, and canonical consistency. The generated tags are a starting point for that review, not a live crawl of the site.
Technical Details:
An HTML hreflang entry uses a link element with rel="alternate", a locale value in hreflang, and an absolute page URL in href. Search engines read the set as a group of alternate representations of the current document. The group should include the current page itself, because self-reference confirms that the page belongs to the same cluster it publishes.
Locale values usually start with a two-letter language code such as en, ms, or fr. A region can be added with a hyphen, such as en-GB or ms-MY. The special x-default value points to a language-neutral fallback, often a selector page, a global home page, or the best default version when no listed locale matches.
Rule Core
The generated head block follows a narrow rule set. Every valid alternate becomes one link element, duplicate locale handling decides which row feeds the output, and warning rows remain visible for review instead of silently disappearing.
locale, URL, optional label -> normalize locale -> validate absolute URL -> choose duplicate row
valid alternates + optional x-default -> selected order -> <link rel="alternate" hreflang="..." href="..." />
cluster audit -> self-reference, x-default, duplicate locale, language fallback, return-link checklist
| Rule Area | Generated Behavior | Review Meaning |
|---|---|---|
| Row parsing | Rows can be separated as CSV, tab, pipe, or first-space fields. The first value is the locale, the second value is the URL, and later text becomes the label. | A spreadsheet export can feed the generator as long as each line keeps the locale and URL in the first two positions. |
| Locale shape | Language-only values, language-region values, and x-default are accepted. Extended subtags are allowed with a warning to review search engine support. |
Use common values such as en, en-US, and ms-MY unless a script or extended locale is intentional. |
| Locale normalization | When enabled, underscores become hyphens, language subtags become lowercase, two-letter regions become uppercase, and four-letter script subtags use title case. | Mixed spreadsheet values such as EN_us become the more familiar en-US form before output. |
| URL validation | Only fully qualified http:// and https:// URLs are eligible for generated tags. |
Relative paths and missing schemes are blocking errors because the final cluster needs absolute destinations. |
| Duplicates | The duplicate policy keeps either the first valid row or the last valid row for a repeated locale. The ledger marks the kept and skipped rows. | Duplicate locales deserve review because a cluster should publish one canonical URL per locale value. |
| Fallback coverage | An x-default row can be added when no source row already provides one. Regional groups with multiple variants and no language-wide row raise a warning. |
A generic language page can catch users outside listed regions, while x-default catches unmatched language or region settings. |
Generation runs in the browser from the rows provided on the page. A local text or CSV import is read into the page, then the same parsing and audit rules produce the head block, ledger, implementation audit, and structured JSON payload.
| Audit Check | When It Warns | Practical Response |
|---|---|---|
| Self-reference | The current page locale is not present in the selected alternate set. | Add the current page URL for that locale before installing the cluster on that page. |
x-default |
No fallback row exists and the add-fallback switch is off or has an invalid URL. | Add a selector, global home page, or accepted default URL when the site has a clear fallback destination. |
| Language fallback rows | A language has more than one regional page, such as en-US and en-GB, without a broader en row. |
Add a language-wide URL if the site has one, or document why only regional pages should be listed. |
| Return-link discipline | This is shown as a checklist item rather than a live page crawl. | After publishing, confirm every localized page points back to every other page in the same cluster. |
| Head placement | This is shown as a checklist item for implementation review. | Place the link elements inside the document head and avoid mixing media or type alternates into the same tags. |
The output is deterministic for a given row set and duplicate policy. Changing sort order affects the display order only. Changing duplicate policy can change which URL appears for a repeated locale, so compare the ledger before copying a revised head block.
Everyday Use & Decision Guide:
Start with one row per localized page. Put the locale first and the absolute URL second, then add an optional label if it helps the review. A simple spreadsheet with columns for locale, URL, and label works well because the same rows can be pasted, uploaded as text, or normalized before copying the generated tags.
Set the current page locale to the page where the cluster will be installed first. If the summary reports a missing self-reference, add that page to the rows before copying anything. Hreflang annotations are meant to be reciprocal, so every matching localized page should receive the same final alternate set.
Use x-default when the site has a real fallback destination. A language selector, global home page, or accepted default version is a better target than guessing at one regional page. If a source row already contains x-default, the fallback switch does not create a second fallback row.
- Keep Input order while comparing against a spreadsheet or ticket.
- Choose Locale A-Z when the tags should be easier to scan in code review.
- Choose URL A-Z when hostnames or path groups matter more than locale order.
- Use Keep first valid row when later duplicate spreadsheet rows should not override earlier rows.
- Use Keep last valid row only when later rows intentionally replace earlier entries.
The tool is a good fit before a localized page launch, a CMS migration, or a code review where a static head block is needed. It is not a substitute for checking live status codes, canonical tags, robots rules, or the real reciprocal links after deployment.
Treat Review hreflang cluster as a pause point. Blocking errors mean the generated head block should not be copied. Warnings mean tags may exist, but the self-reference, fallback, duplicate, or language-coverage issue should be resolved or consciously accepted first.
Step-by-Step Guide:
Build one clean alternate set, review the audit, then install the same set across the localized page family.
- Paste locale and URL rows into Locale URL rows, or browse for a CSV or text file with the same row shape.
- Set Current page locale to the page being prepared, such as
en,en-GB, orms-MY. - Enable Add x-default fallback when missing only when the fallback URL is a page users should land on when their language or region is not listed.
- Open Advanced if locale case, output order, or duplicate handling needs to match a review convention.
- Check the summary badges. Clear errors first, then review warnings for self-reference, fallback, duplicates, and language-wide coverage.
- Open Alternate Ledger to confirm each locale, URL, label, status, and duplicate decision before using the head block.
- Open Implementation Audit and use the checklist rows for return links, head placement, and cross-domain review.
- Copy the Head Tags output only after the cluster is ready, then place the identical alternate set in the head of every equivalent localized page.
Interpreting Results:
The top summary is the first status check. Add locale rows means no valid alternates are ready. Fix required means a blocking error, usually a missing locale or non-absolute URL, must be corrected before the output should be used. links ready means the head block exists, but warnings can still require review.
| Visible Cue | Best Reading | Next Check |
|---|---|---|
| head links | The count of valid alternates selected for generated link elements. | Compare the count with the expected number of localized pages plus any fallback row. |
| missing self | The current page locale does not appear in the selected alternates. | Add the current page URL or correct the current locale value. |
| no x-default | No fallback URL is present in the selected alternates. | Add one only when the site has a real fallback destination. |
| errors | At least one row is missing a required value or uses a URL shape that cannot be generated. | Fix the row before copying the head block. |
| warnings | The head block can be generated, but one or more review conditions remain. | Read the alert list and audit table before deciding whether the cluster is acceptable. |
| Skipped ledger rows | A valid row was not selected, usually because another row used the same locale. | Confirm the duplicate policy selected the intended URL. |
The generated head block should match the ledger, not the raw rows. Rows with errors do not feed generated tags, and duplicate rows may be skipped based on the selected policy. If the head block has fewer links than expected, the ledger is the fastest way to find the missing or skipped row.
A clear audit does not prove live correctness. The page does not fetch every listed URL or compare published return links. After installation, use a crawler, rendered-page inspection, or search-console workflow to confirm the tags appear in the head of each page and point back to the full cluster.
Worked Examples:
Three localized pages with a fallback
Rows for en, en-GB, and ms-MY with absolute URLs produce three alternate links. If Add x-default fallback when missing is enabled and the fallback URL is valid, the head block contains four links. The audit should show self-reference when the current page locale matches one of the selected rows.
Duplicate locale from a spreadsheet
A pasted list includes two en-US rows, one for an old path and one for a new path. With Keep first valid row, the old path remains in the generated head block and the later row is skipped. With Keep last valid row, the new path is selected. The duplicate warning remains useful because only one of those URLs should represent en-US in the final cluster.
Regional pages without a language-wide page
A cluster with en-US, en-GB, and en-AU can generate tags, but the audit warns that no generic en row exists. If the site has a broader English page for users outside those regions, add it. If each region is intentionally separate and no generic page exists, document that decision before launch review.
Relative paths that block output
A row such as fr, /fr/product is not eligible for a generated tag because the URL is not fully qualified. Change it to an absolute URL such as https://example.com/fr/product. Once the row clears validation, it can appear in the ledger and head block.
FAQ:
Does every page need to include itself?
Yes. Each page in the alternate set should include a link for its own locale as well as links to the other localized versions. The self-reference check exists because missing self-links are a common hreflang mistake.
Is x-default required?
No. It is useful when there is a language-neutral selector, global page, or accepted default URL for unmatched users. If there is no suitable fallback page, it is better to omit it than to point to a misleading destination.
Can alternates use different hostnames?
Yes, cross-domain alternates can be valid when the page family is equivalent and return links are consistent. The audit notes how many hostnames appear so the cross-domain setup receives explicit review.
Does the generated code verify live pages?
No. The generator checks the row structure, locale shape, selected alternates, and implementation checklist items. It does not crawl the destination URLs or prove that published pages already contain matching return links.
Should canonical tags point to one language version?
Usually no. Equivalent localized pages normally keep their own self-canonical URLs while hreflang links connect the variants. Canonical and hreflang signals should not fight each other during launch review.
Glossary:
- Hreflang
- An HTML annotation that identifies an alternate language or regional version of a page.
- Locale
- A language value such as
en, sometimes paired with a region value such asen-GB. x-default- A fallback value for users whose language or region is not explicitly listed by the alternate set.
- Self-reference
- The link row where a page lists its own locale and URL as part of the alternate cluster.
- Return link
- The reciprocal link from one localized page back to another page in the same cluster.
- Fully qualified URL
- A complete URL with scheme and host, such as
https://example.com/gb/page.