What Is Hreflang Tag?
The hreflang tag is an HTML link attribute, written as <link rel="alternate" hreflang="en-gb" href="...">, that tells search engines which language and regional versions of a page exist and which URL suits which audience. It helps Google show each searcher the version in their language or for their country, for example the UK English page to searchers in the UK and the German page to searchers in Germany.
What Is the Hreflang Tag?
Hreflang matters whenever the same content exists in more than one language, or in one language adapted for different countries, such as English pages for the US, UK and Australia with different prices, spelling and contact details. Without it, Google may show the wrong version, for example a US page with dollar prices to a searcher in London, or treat near-identical regional pages as duplicates. The attribute value is a language code in ISO 639-1 format (en, de, fr), optionally followed by a region code in ISO 3166-1 alpha-2 format (en-gb, en-us, de-at). A region can never be used on its own, so gb alone is invalid. The special value x-default marks the page to show when no other version matches, typically a language selector or the main international page. Hreflang does not translate anything or pass rankings between pages; it only helps search engines swap in the most appropriate URL.
How the Hreflang Tag Works
There are three ways to declare hreflang, and you should use only one for each set of pages. The most common is <link> elements in the <head> of every version: the UK page lists itself and every alternate, such as <link rel="alternate" hreflang="en-gb" href="https://example.com/uk/">, <link rel="alternate" hreflang="en-us" href="https://example.com/us/">, <link rel="alternate" hreflang="de" href="https://example.com/de/"> and <link rel="alternate" hreflang="x-default" href="https://example.com/">. The second is an HTTP Link header, which is useful for non-HTML files such as PDFs. The third is the XML sitemap, where each <url> entry contains <xhtml:link rel="alternate" hreflang="..." href="..."/> children; this keeps the HTML lighter and is easier to manage on large sites. Whichever method you choose, the annotations must be bidirectional: if the UK page points to the German page, the German page must point back to the UK page, otherwise Google may ignore the pair. Each version should also include a reference to itself. Google reads these clusters when it crawls, groups the URLs as alternates, and at query time serves the version that best matches the searcher's language and location. The annotations are signals rather than directives, so Google can still show another version if it judges it more relevant.
Best Practices for the Hreflang Tag
Use fully qualified absolute URLs, including https://, in every annotation. Point hreflang only at canonical, indexable pages that return 200: a URL that redirects, returns a 404, carries noindex or canonicalises to another page breaks the cluster. Each language version should have a self-referencing canonical; never canonicalise the French page to the English one, because that tells Google the French page is a duplicate and its hreflang is then ignored. Check codes carefully. The most common mistake is en-uk, which is invalid because the ISO region code for the United Kingdom is gb, giving en-gb. Also set the lang attribute on each page's <html> element (for example <html lang="en-GB">), which helps browsers, screen readers and translation tools even though it is separate from hreflang. Avoid automatically redirecting visitors based on IP address or browser language, because Googlebot mostly crawls from US IP addresses and may never see the other versions; offer a visible language or country switcher instead. Keep the annotations in sync whenever you add or remove a version, which is much easier when they are generated from one data source or listed in the sitemap. Finally, audit them with the URL Inspection tool, a crawler such as Screaming Frog, or an hreflang validator after every structural change.
Hreflang Tag and Canvas Builder
You can describe a site to Canvas Builder in any language, so it can be used to create separate language or regional versions of a site, each generated with semantic HTML and SEO meta in the <head>. Do not assume hreflang annotations are present: add the <link rel="alternate"> set to each version's head, or to your sitemap, before you publish or export, and the free Hreflang Tag Generator on canvasbuilder.co can build the tags for you.
Frequently asked questions
Is hreflang a ranking factor?
No. Hreflang does not improve rankings; it helps Google choose which of your existing pages to show to each searcher. The benefit is that visitors land on the right language or regional version, which improves their experience and reduces the chance they leave straight away.
What is x-default in hreflang?
x-default is a special hreflang value that identifies the fallback page for users whose language or region does not match any listed version. It usually points to a language selection page or the main international version of the site. It is optional but recommended.
Do I need hreflang for a single-language website?
No. Hreflang is only needed when you have several versions of a page for different languages or regions. A single-language site should still set the lang attribute on the <html> element, but it does not need hreflang annotations.
Should hreflang go in the HTML or in the sitemap?
Both methods work for Google, so choose the one that is easier to maintain. HTML <link> tags suit small sites, while sitemap annotations are easier to manage for large sites with many language versions, because each page's head stays short. Use one method consistently rather than mixing them.