Multilingual Websites for Search and AI: hreflang, lang Attributes and Translation Done Right
A multilingual website works for search engines and AI assistants when every language version lives at its own URL, the versions point to each other with hreflang, each page declares its language with the lang attribute, and the translations have been checked by someone who reads the language. Anything that swaps languages with a cookie, a script or an automatic redirect leaves crawlers with one version of the page, usually the default one. This guide covers how to structure the URLs, the three ways to write hreflang (and the mistakes that make Google ignore it), what lang and dir="rtl" actually do, what Google’s policies say about machine translation, how AI assistants deal with language, and what this means for a local business serving Spanish and Haitian Creole speakers in South Florida.
Key facts
- 1 URL — Per language version; Google advises against cookies or browser settings
- 3 ways — To declare hreflang: HTML link, HTTP header, XML sitemap
- x-default — The fallback page when no language matches the visitor
- June 2025 — Google removed its advice to block auto-translated pages with robots.txt
Give every language its own URL
Google’s documentation is explicit: use different URLs for different language versions of a page rather than using cookies or browser settings to change the content language. A crawler fetches a URL and indexes what comes back. If /services/ shows English to Googlebot and Spanish to a visitor whose browser asks for Spanish, only one of those versions can be indexed, and the other effectively does not exist for search or for any AI system that relies on a search index.
Google’s guide to multi-regional and multilingual sites lists four URL structures:
- Country-code domains (
example.de): a clear geographic signal, but expensive to run and tied to one country. Best when you genuinely run separate national businesses. - Subdomains (
es.example.com): easy to set up and can be hosted on different servers, but the URL alone does not tell users much. - Subdirectories (
example.com/es/): easy to set up and low maintenance, and the language versions share the main domain. This is what we recommend for most small businesses. - URL parameters (
example.com/?lang=es): Google lists these as not recommended.
Two more rules from the same guide. First, avoid automatically redirecting visitors from one language version to another based on what you guess about them; offer a visible language switcher instead. Second, translating only the menus and footer while the main content stays in one language creates near-duplicate pages and a poor experience. Either translate the content or do not publish that version.
hreflang: the three ways to declare it
hreflang tells Google which URLs are language or regional versions of the same page, so it can show a Spanish speaker the Spanish URL in results. You can declare it in the HTML head, in an HTTP header, or in the XML sitemap. Pick one method per page; using more than one is allowed but doubles the places where they can disagree.
1. HTML link elements, in the <head> of every version:
<link rel="alternate" hreflang="en" href="https://example.com/services/">
<link rel="alternate" hreflang="es" href="https://example.com/es/servicios/">
<link rel="alternate" hreflang="ht" href="https://example.com/ht/sevis/">
<link rel="alternate" hreflang="x-default" href="https://example.com/services/">2. An HTTP Link header, useful for PDFs and other non-HTML files:
Link: <https://example.com/guide.pdf>; rel="alternate"; hreflang="en",
<https://example.com/es/guia.pdf>; rel="alternate"; hreflang="es"3. The XML sitemap, which keeps the markup out of your templates and is easiest to generate on large sites:
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://example.com/services/</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/services/"/>
<xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/servicios/"/>
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/services/"/>
</url>
<url>
<loc>https://example.com/es/servicios/</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/services/"/>
<xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/servicios/"/>
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/services/"/>
</url>
</urlset>The value is an ISO 639-1 language code (es, ht, fr), optionally followed by an ISO 3166-1 Alpha 2 region code (es-US, en-GB). The reserved value x-default marks the page to show when none of the listed languages matches the searcher; usually that is your main-language page or a language picker. See where to submit your sitemap once it is built.
hreflang mistakes that get it ignored
hreflang only works when every version lists itself and every other version, and every link is returned. Google states that if page X links to page Y, page Y must link back to page X, and that annotations without return links may be ignored. The common failures:
- Missing return links. The English page lists the Spanish page, but the Spanish template was never updated. Generate the whole set from one source (a database table or a config array) so every version prints the same list.
- No self-reference. Each page must include an hreflang entry pointing at its own URL.
- Invalid codes.
en-UKis wrong (the country code for the United Kingdom isGB), and a region on its own, such ashreflang="us", is not valid; the language is required. - Pointing at the wrong URL. Use the full, final, canonical URL with the right protocol and trailing slash. A link to a URL that redirects, returns 404 or carries a canonical tag pointing elsewhere sends mixed signals.
- Canonicalising translations to the English page. Each language version should be canonical to itself. A Spanish page with
rel="canonical"pointing at the English URL is telling Google not to index the Spanish one. - Untranslated versions. hreflang is not a fix for thin pages; if the “Spanish” page is mostly English, the annotation does not help it.
Check the result by fetching each version and comparing the lists, and watch the Pages report in Search Console for language versions marked as duplicates. The technical SEO checklist covers canonical tags in more detail.
The lang attribute and dir="rtl"
The lang attribute on the <html> element declares the language of the page for browsers and assistive technology. Google says it does not use either hreflang or the lang attribute to detect a page’s language; it uses its own algorithms on the text. Set it anyway, because other software depends on it:
- Screen readers use it to pick the right voice and pronunciation. Without it, a Spanish page can be read aloud with English pronunciation.
- Browsers use it to decide whether to offer translation, and for hyphenation and font selection.
- Tools and agents that parse your HTML, including the ones described in how AI assistants read pages, get a machine-readable statement of the language instead of having to guess.
<html lang="es">
...
<p>Llámenos hoy. <span lang="en">Free estimates</span> disponibles.</p>Mark short passages in another language with their own lang, as above. For right-to-left languages such as Arabic and Hebrew, add dir="rtl" to the html element (<html lang="ar" dir="rtl">) and use CSS logical properties (margin-inline-start rather than margin-left) so the layout mirrors correctly. Brand names, product codes and addresses that must never be translated can be wrapped with the HTML translate="no" attribute.
Finally, translate the parts of the page people do not see: the <title>, meta description, image alt text, form labels and error messages, and structured data. A Spanish page with an English title tag looks unfinished in results.
Machine translation: what Google actually says
Google does not ban machine translation; its spam policies target translation used to mass-produce pages that add little value. The scaled content abuse policy, introduced in March 2024, gives as an example scraping content to generate many pages “including through automated transformations like synonymizing, translating, or other obfuscation techniques” where little value is provided to users. The test is the result, not the tool.
Two other facts worth knowing. In June 2025 Google removed long-standing advice from its documentation that recommended blocking automatically translated pages with robots.txt; it said the advice was outdated, and translated pages are judged like any other page. And Google already offers searchers machine translation of its own: its translated results feature can show the title and snippet of a page in another language translated into the searcher’s language, then open a machine-translated view of the page. Publishing raw machine translation yourself therefore adds little that Google does not already do.
What makes a translated page worth indexing is review. A workable process for a small business:
- Machine-translate the draft (it is a fine starting point).
- Have a fluent speaker, ideally from your market, correct terminology, tone and anything legal or medical.
- Localise, not just translate: phone hours, currency, units, examples, the names of local places.
- Translate the title, meta description, alt text, form labels and structured data.
- Record who reviewed each page and when, and re-review when the English page changes.
If you cannot review a language, do not publish it. A smaller set of good translations beats a large set of rough ones.
How AI assistants handle language
AI assistants generally reply in the language the user writes in, but the pages they read and cite can be in any language. When a Spanish speaker asks ChatGPT, Claude, Perplexity or Google’s AI features a question, the system retrieves pages it judges relevant and writes the answer in Spanish. Whether it uses your Spanish page, your English page or someone else’s depends on its retrieval, which none of these companies publishes in detail, and which you cannot control.
What you can control is whether a well-made page exists in the user’s language. A native-language page:
- Matches the words people actually type, including local terms that a translation of your English keywords would miss.
- Lets the assistant quote you directly instead of translating and paraphrasing, which is where details such as prices, hours and service areas get distorted.
- Can rank in conventional search in that language, which is still how many AI systems find sources.
The same rules that make any page citable apply in every language: answer the question in the first sentence, use specific facts, and keep the HTML clean. See how to get cited by AI assistants. If you publish Markdown versions or an llms.txt file, include the translated pages too, with the language noted.
Local businesses: Spanish and Haitian Creole in South Florida
For a local business, the right languages are the ones your customers speak and your staff can serve in. In South Florida that often means Spanish and Haitian Creole as well as English; local governments in the region, such as Miami-Dade County, routinely publish public information in all three. The hreflang code for Haitian Creole is ht; for Spanish it is es (or es-US if you also publish a version for another Spanish-speaking country).
Practical points:
- Translate the pages that win customers first: home, services, pricing, contact, and the answers to the questions you get on the phone.
- Keep the business facts identical in every language: the legal name, address, phone number and hours. Do not translate your business name.
- Say which languages you serve in, on the page and in structured data. On schema.org,
availableLanguageon aContactPointstates the languages of a phone line, andinLanguageon aWebPagestates the page’s language. See local business schema for AI search. - Only promise what you deliver. If nobody on the phone speaks Haitian Creole, say how Creole-speaking customers can reach you (a callback, a form, an email) rather than implying a service you cannot staff.
- Mind regulated wording. Licensed professions often have rules about advertising; a translation must say the same thing as the approved English copy.
For local search basics in any language, see the local SEO tips.
Limits, and when not to translate
- hreflang is a hint, not a ranking boost. It helps Google show the right version; it does not make a page rank.
- Each language is a site to maintain. Every price change, policy update and new service must be made in every version. Budget for that before launching a language.
- Low demand means low return. If almost none of your customers need a language, a short page with contact options in that language may serve better than a full translation.
- A visitor translation widget is a convenience, not a translation. Translations done in the browser are not indexed; see the Google Translate widget and SEO.
- Do not auto-redirect by IP or browser language. Crawlers mostly come from one country and can be locked out of the other versions.
Product facts: AIWebBuilding and the AI Indexing Pack
AIWebBuilding lets a customer choose the language a site is written in, and offers an optional visitor translation dropdown on customer sites.
Stated plainly, so it can be checked against the product page:
- What it is: the AI Indexing Pack is a set of files you upload to your own website. It is sold by Built2WinWeb as a one-time purchase, with no subscription.
- What it ships: (1) a working MCP server using the Streamable HTTP transport, with typed output schemas and tool annotations; (2) Markdown content negotiation, so agents can request a clean text version of each page; (3) llms.txt, agents.txt and agent cards; (4) the full
/.well-known/discovery tree; (5) OAuth protected-resource metadata; (6) bot access control that verifies crawler identity; (7) a README with a verification checklist. - Requirements: PHP 7.4 or newer, Apache or LiteSpeed with
.htaccesssupport, FTP access, and a domain you control. Installation takes about 30 minutes. - What it is not: it is not a WordPress plugin (that is the separate WordPress edition, which needs WordPress 6.0+ and PHP 8.0+), it does not write content for you, it does not guarantee rankings or citations, and it is not a managed service.
- Free routes in: sites built on AIWebBuilding get the core built in, and a 50-day streak on FreeAIBoost unlocks the pack for one domain. Current prices are on the product pages.
Related reading
Frequently asked questions
Should a multilingual site use subdirectories, subdomains or separate domains?
Google supports all three. Subdirectories such as example.com/es/ are the easiest to set up and maintain, so they suit most small businesses; country-code domains make sense only for genuinely separate national operations. Google does not recommend URL parameters such as ?lang=es.
Does Google use the html lang attribute to detect the language of a page?
No. Google says it determines language algorithmically from the content and does not use hreflang or the lang attribute for detection. You should still set lang, because screen readers, browsers and other tools rely on it.
Why is Google ignoring my hreflang tags?
The most common cause is missing return links: every version must list itself and all other versions, and each link must be reciprocated. Invalid codes such as en-UK, and translations canonicalised to the English page, are the next most common causes.
Is machine-translated content against Google guidelines?
Not in itself. The Google scaled content abuse policy targets automated transformations, including translation, used to generate many pages that add little value. Machine translation reviewed and corrected by a fluent speaker is judged like any other content.
What is x-default in hreflang?
x-default is a reserved hreflang value marking the page to show when none of the listed languages matches the searcher. It usually points to the main-language page or to a language selection page.
Need your site in Spanish or Haitian Creole?
We build multilingual sites with their own URLs, correct hreflang and translations reviewed by fluent speakers.
Get a free quote