Open a Ukrainian page in your browser and it can look right even when its language annotations are wrong. Our tarot app uses /ua/ in its URLs. Copying that route segment straight into hreflang would turn a perfectly good address into an invalid language code. Ukrainian is uk. The route and the language tag are two separate pieces of data.
What the server actually returns
We checked the three translations of KaelisAI’s family tarot reading. All three returned HTTP 200. Here are two of them, using paths for readability:
| URL path | HTML lang | Self-referencing hreflang | Canonical path |
|---|---|---|---|
| /en/tarot/family | en-US | en | /en/tarot/family |
| /ua/tarot/family | uk-UA | uk | /ua/tarot/family |
Both responses named the English page as the default. Both listed the Ukrainian page under uk; the Ukrainian response also pointed back to the English page under en. The values for the document language and the alternate do not have to be identical. In this example one includes a region and the other addresses speakers of the language more broadly.
A check you can run before deploying
Save this as alternates.py. Run it with the addresses of two translated pages: python alternates.py URL_A URL_B. It reads the HTML over HTTP without running the site's JavaScript.
from html.parser import HTMLParser from sys import argv from urllib.request import urlopen class Alternates(HTMLParser): def handle_starttag(self, tag, attributes): attrs = dict(attributes) if tag == 'html': print('document language:', attrs.get('lang')) if tag != 'link': return rel = attrs.get('rel', '').split() if 'canonical' in rel: print('canonical:', attrs.get('href')) if 'alternate' in rel and 'hreflang' in attrs: print(attrs['hreflang'], '->', attrs.get('href')) for url in argv[1:]: with urlopen(url, timeout=15) as response: print('\n', response.status, response.geturl()) encoding = response.headers.get_content_charset() or 'utf-8' Alternates().feed(response.read().decode(encoding)) Look for the return link. If page A names page B but the reverse line is missing, the language switcher may still work and the page may still render correctly. This small test catches the mismatch at the point where it enters the response. It also shows the final URL after redirects, so you can spot a translated page that quietly redirects to the default language.
On a site that serves its alternates through HTTP headers or a sitemap, inspect that source instead. Google’s guide to localized versions covers all three methods and the return-link requirement.
The KaelisAI team prepared this article with AI assistance. The HTTP responses and language annotations above were checked against the live pages.
