If your website has more than one language or targets more than one country, there is a good chance Google is showing the wrong version to some of your visitors. A shopper in London lands on your US page with dollar prices. A reader in Madrid gets the English article instead of the Spanish one you paid to translate. Nothing is technically broken, yet you are losing clicks, sales and trust every day.
Hreflang tags fix this. They are small lines of HTML that tell search engines which version of a page belongs to which language and region. The problem is that writing them by hand is fiddly. One missing return link or one wrong code like en-uk and the whole set can be ignored.
That is why we built the free Hreflang Tag Generator on SEO Stack Hub. You type each language-region code with its URL, add an x-default page, and the tool writes the complete set of tags for you, ready to paste. In this guide we will explain how hreflang works, walk through the tool step by step, show real examples, and cover the mistakes that quietly break international SEO.

A hreflang tag is an HTML attribute that tells Google, and other search engines that support it, about alternate versions of the same page. Each version targets a different language, or a language in a specific country. The tag lives in the <head> of the page and looks like this:
<link rel="alternate" hreflang="en-gb" href="https://example.com/uk/" />
This one line says: “There is a version of this page for English speakers in the United Kingdom, and it lives at this URL.” On its own, one line is not enough. Every version of the page must list every other version, including itself. That full set is what search engines use to decide which URL to show in each country.
en, es, de, ar, ur). The optional region uses ISO 3166-1 alpha-2 (for example GB, US, AE, PK).Codes are not case sensitive, so en-GB and en-gb both work. What matters is that the codes are valid. The UK is gb, not uk, which is one of the most common errors we see.
You do not always need a country. If you have one Spanish page for all Spanish speakers, hreflang="es" is perfect. You only add a region when you have different versions for different countries that share a language, such as separate English pages for the US, UK and Australia with different prices, spelling or shipping details. You can also combine both: es as a catch-all for Spanish speakers, and es-mx for a page made specifically for Mexico.
One thing you cannot do is use a country on its own. hreflang="gb" is invalid because gb is not a language code. The language always comes first.
Hreflang is not a ranking boost in the usual sense. It will not push a weak page to the top of Google. What it does is make sure the right page from your site appears for the right audience. That has a direct effect on the numbers you care about.
If you run an online store that ships to several countries, a SaaS product with translated pages, or a blog with Urdu and English editions, hreflang is one of the highest value technical fixes you can make.
The x-default value is a special hreflang value for visitors who do not match any of the languages or regions you listed. Imagine you have English pages for the US and UK and a German page for Germany. A searcher in Brazil does not match any of them. Without x-default, Google has to guess. With x-default, you tell it exactly where to send them.
Most sites point x-default at one of these:
Our hreflang generator has a separate field for x-default so you never forget it. It is technically optional, but we recommend adding it to every set.
This is the part that trips up most people. Hreflang only works when the tags are reciprocal. If your UK page says “my US version is at /us/”, then the US page must also say “my UK version is at /uk/”. If the return link is missing, Google may ignore the pair.
The simplest way to stay safe is to use the exact same block of tags on every version. Each page lists all versions, including a self-referencing tag that points to itself. That is exactly what the Hreflang Tag Generator outputs: one complete block that you paste, unchanged, into the head of every version.
Here is what a correct set looks like for a page with three versions plus x-default:
<link rel="alternate" hreflang="en-us" href="https://example.com/us/pricing/" />
<link rel="alternate" hreflang="en-gb" href="https://example.com/uk/pricing/" />
<link rel="alternate" hreflang="de-de" href="https://example.com/de/preise/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/pricing/" />
The same four lines go on the US page, the UK page and the German page. Notice that the URLs do not need to match in structure. The German page can have a German slug. What matters is that every page lists every other page.

The tool runs in your browser, needs no sign-up and takes less than a minute once you have your URLs ready. Here is the full process.
Before you open the tool, write down every language or country version of the page you are working on. Use full URLs, not paths. For example:
Make sure each URL loads with a 200 status, is not redirected and is not blocked by noindex. Hreflang pointing to a redirect is one of the fastest ways to get the whole set ignored. If you moved pages recently, create clean redirects with our 301 Redirect Generator first, then use the final URLs in your hreflang set.
For each URL, choose a code. Use the language code alone if the page is for all speakers of that language. Add a region code if the page is tailored to one country. For the list above, the codes would be en-us, en-gb, en-pk, ur-pk and ar-ae.
Open the Hreflang Tag Generator. In the main box, enter one version per line in the format language-region, URL. For example:
en-us, https://example.com/us/
en-gb, https://example.com/uk/
en-pk, https://example.com/pk/
ur-pk, https://example.com/ur/
ar-ae, https://example.com/ae-ar/
In the x-default field, enter the URL that should catch everyone else, such as your global English page or a country selector.
Press Generate tags. The tool writes the full set of <link rel="alternate"> tags, including the x-default line, in the correct format.
Copy the output and paste it into the <head> of every URL in the list. Do not edit it per page. The identical block on every version is what makes the return links work automatically.
Hreflang works page by page, not site-wide. Your homepage needs its own set, your pricing page needs its own set, and each blog post with translations needs its own set. For large sites, keep a simple spreadsheet with one row per page group and one column per language so nothing gets missed.
Google accepts hreflang in three places. You only need one method per page, and mixing them on the same URLs can create conflicting signals.
This is what the generator output is designed for. Paste the tags inside <head>, ideally near your canonical tag. On WordPress, you can add them through your theme’s header, a header-code plugin, or the multilingual plugin you already use. Keep in mind that the canonical on each version should point to itself, not to another language. We explain canonical setup in detail in our guide to canonical URLs in WordPress.
For files that have no HTML head, like PDFs, you can send hreflang in the HTTP Link header. This is handled on the server, so you will usually need a developer or host to set it up.
Large sites with thousands of translated URLs often prefer to list hreflang inside the sitemap using xhtml:link entries. This keeps the HTML clean and makes changes easier to manage in one place. If your sitemap is already huge, read our tips on splitting large sitemaps for faster indexing before adding more entries.
Here are some common setups and what the input for our generator would look like.
One English version for everyone and one Urdu version for everyone. No country codes needed.
en, https://example.com/blog/seo-tips/
ur, https://example.com/ur/blog/seo-tips/
x-default: https://example.com/blog/seo-tips/
Same language, different currencies and shipping. Country codes are essential here.
en-us, https://shop.example.com/us/blue-shoes/
en-gb, https://shop.example.com/uk/blue-shoes/
en-au, https://shop.example.com/au/blue-shoes/
x-default: https://shop.example.com/blue-shoes/
en-ae, https://example.ae/en/
ar-ae, https://example.ae/ar/
x-default: https://example.ae/en/
In each case, the generator produces one block that you place on every listed URL.
Hreflang errors are silent. Your pages still load, nothing looks wrong to visitors, but Google quietly ignores the tags. Watch out for these.
en-uk instead of en-gb, or ar-uae instead of ar-ae. Always use two-letter ISO codes./uk/ instead of https://example.com/uk/. Hreflang needs full absolute URLs.A quick tip: when you migrate an old domain or merge country sites, check the history of each domain with our Domain Age Checker. It helps you decide which domain should become the main x-default destination.

After you publish the tags, give Google some time to recrawl the pages. Then run these checks:
If something looks off, the fix is almost always one of the mistakes above. Regenerate the block, paste it again on every version, and request a recrawl.
Hreflang decides which version Google shows. It does not make a version rank on its own. Each regional page still needs good content, local keywords and links from that market. Here is how to build out the rest of your international SEO with free resources on SEO Stack Hub.
People in different countries search with different words. Americans search for “sneakers”, Britons for “trainers”. Start each market with a seed term and expand it using the Long-Tail Keyword Generator. Then check whether each phrase is informational or commercial with the Search Intent Checker, so the page format matches what searchers want in that country.
A German page with only American backlinks is at a disadvantage in Germany. Look for publishers in each target country. Our Backlink Opportunity Finder builds ready-made Google searches for guest post and resource pages in your niche, and the guest post marketplace lists sites you can contact directly.
Adding your site to a quality directory helps new markets discover you. You can add your business to the SEO Stack Hub website directory through the submit your site page.
If you are expanding into several countries at once, a local partner can save months of trial and error. Our SEO agency directory lists agencies by country and service. Today we added five new profiles with international experience, including The SEO Works in the UK, Techmagnate in India, Trafiki Digital Marketing in Dubai and London, internetwarriors in Germany and StudioHawk in Australia. Several of them list international SEO among their services, so they are worth contacting if hreflang is just the start of a bigger multi-country project.
Save this list and run through it each time you launch a new language or country.
gb, the UAE is ae.Yes. The tool is completely free, needs no account and runs in your browser. You can generate as many sets as you like. You will find it, along with more than 25 other free tools, on our free SEO tools page.
Not usually. If you have one version of each page in one language for everyone, there is nothing for hreflang to choose between. You only need it when you have two or more versions of the same content aimed at different languages or countries.
Not directly. It helps Google show the most suitable version to each searcher. That usually improves click-through rate and engagement in each market, which is valuable, but you still need strong content and links for each version to rank well.
Yes. Hreflang works across subfolders (example.com/uk/), subdomains (uk.example.com) and separate country domains (example.co.uk). Just use the full URL of each version in the generator.
Google simply ignores the invalid tag. Your page will not be penalised, but that version will not get the targeting benefit. Regenerate the set with correct codes and paste it again.
Only if the homepage is the right fallback for that specific page. For a pricing page, x-default should point to the global or default pricing page, not the homepage. Each page group has its own x-default.
Google has to recrawl every version in the set before it can connect them. On a small site that can be days; on a large site it can take longer. Keeping your sitemaps up to date helps, and our XML sitemaps guide explains how.
Post your question on the SEO Q&A section and our team will answer it. You can also follow the latest updates on our SEO news page.
Hreflang looks technical, but the logic is simple: list every version, use the right codes, add x-default, and put the same block on every page. The hard part has always been writing the tags without typos. Our tool removes that step completely.
Open the free Hreflang Tag Generator, enter your URLs and have a clean, correct set of tags in under a minute. Then keep an eye on our What’s new page, where we announce every new tool and feature we add to SEO Stack Hub.