Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Testing hreflang in the HTML response: when /ua/ means uk

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…

When examining the HTML response of a Ukrainian page, it is possible for the page to appear correct even with inaccurate language annotations. The tarot application in question utilizes the "/ua/" segment in its URLs, but simply copying this into hreflang annotations could result in an invalid language code. Ukrainian should be represented as "uk", not "ua".

The server's actual response should be checked for both the HTML language attributes and the hreflang values. In the case of KaelisAI’s family tarot reading page, three translations were examined and all returned a successful HTTP 200 status. Two of the translations used path-based URLs, while the third used the full URL. Both translations indicated the English page as the default, and listed the Ukrainian page under "uk-UA".

The Ukrainian response also referenced the English page under "en". It is not necessary for the document language and alternate hreflang to match exactly. One can include a region code while still addressing speakers of the language more generally. To test for issues before deploying, a Python script called "alternates.py" can be used to inspect the HTML of two translated pages.

The script reads the HTML over HTTP without executing the site's JavaScript. It prints out the document language, canonical link, and alternate hreflang values for each URL provided as command line arguments. Run the script with the URLs of the two pages being compared. The script will also display the final redirected URL, allowing you to identify if a translated page quietly redirects to the default language.

If page A references page B in its hreflang but the reverse is missing, the language switcher may still function correctly, and the page should render properly. For sites that serve their alternate versions through HTTP headers or a sitemap, inspect those sources instead of the HTML. Google provides a comprehensive guide covering all three methods for specifying localized versions, as well as the requirement for the return link.

The KaelisAI team prepared this article with the assistance of AI technology. The HTTP responses and language annotations were verified against the live pages.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

n8n Assistant Adds Self-Healing Workflow Fixes With Human Approval

n8n has introduced a self-healing capability in n8n Assistant that can investigate failed workflow executions, propose a fix, and re-run the workflow to validate that fix.

  • n8n Assistant introduces self-healing workflow fixes
  • Requires human approval for critical actions
  • Currently in preview, not multi-instance Enterprise-ready

More from Tuesday, 1 December 2026 →