{
  "id": 22991801,
  "title": "Testing hreflang in the HTML response: when /ua/ means uk",
  "url": "https://urgent.news/2026/12/01/testing-hreflang-in-the-html-response-when-ua-means-uk",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-12-01T18:31:37.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/kaelisai/testing-hreflang-in-the-html-response-when-ua-means-uk-2d05"
  },
  "original_language": null,
  "account": "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.",
  "summary": "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…",
  "summary_source": "publisher",
  "key_points": [
    "\"/ua/\" segment in URLs may cause invalid language code if copied into hreflang annotations.",
    "Ukrainian should be represented as \"uk\", not \"ua\" in hreflang values.",
    "Python script \"alternates.py\" can test HTML of translated pages for issues."
  ],
  "editors_take": null,
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}