Urgent.News

What's breaking now, across thousands of outlets.

Tech

I built a zero-dependency CLI to audit hreflang (international SEO)

If your site serves multiple languages, hreflang is where SEO quietly breaks: page A links B, B never links back; someone writes en_US instead of en-US ; an alternate points at a redirect; the target canonicalizes somewhere else. None of it is visible in the browser — all of it costs you in the SERPs. hreflang-audit is a single-file Node.js 20+ CLI with zero npm dependencies. It crawls your site…

hreflang-audit is a single-file Node.js 20+ command-line interface (CLI) designed to audit hreflang markup for international SEO. It tackles common mistakes such as invalid ISO language/script/region codes, underscore locales, relative URLs, missing return links, conflicting entries, and broken target URLs. The tool crawls websites or parses XML sitemaps and sitemap indices, examining link rel= alternate hreflang elements, HTTP Link: headers, and xhtml:link sitemap entries.

It offers 11 checks to detect issues, providing both human-readable reports and machine-readable output with exit codes for continuous integration (CI) systems. In addition to a standard CLI, hreflang-audit includes a GitHub Action for automated weekly audits, failing builds when hreflang issues arise. Users can quickly test the tool offline with a demo using the command line: git clone https://github.com/madahzadeh/hreflang-audit.git cd hreflang-audit npm run demo.

The project is open-source under the MIT license. While hreflang-audit provides comprehensive checks, it's important to note that it relies on tolerant regexes for HTML parsing, does not execute JavaScript-rendered pages, and serves as a complementary tool rather than a replacement for Google Search Console's reports. The repository is available at github.com/madahzadeh/hreflang-audit, and the creators welcome feedback and issue reports. Currently, sitemap/HTML mismatch detection is planned for future enhancements.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Wednesday 26 August →