Hreflang fails quietly. When two language pages do not point at each other, Google does not show an error in your browser or in the page. The annotation simply does not do its job, and the first sign is the wrong language version ranking in the wrong country.
This tutorial builds a small checker that fetches one page, follows the alternates it lists, and reports missing return links, missing self-references, malformed codes and relative URLs. It uses only the Python standard library.
What the rules actually say
Everything below comes from Google's page on localized versions. I read it in full before writing the code.
Every version must list itself and all other versions, including the default page.
Alternate URLs must be fully qualified, with the protocol. A root-relative path like /de/ is not enough.
Links must be reciprocal.…