Node CLI · v1.0.0 · MIT
An hreflang checker for the terminal and CI
crawlcove-hreflang-checker is the command line half of the hreflang checker on this site. Give it a localised page and it reads the hreflang annotations from both places Google looks, the link tags in the head and the HTTP Link response header, validates the language and region codes, confirms a self-referencing tag and an x-default, and fetches each alternate to check that it links back. Give it a sitemap instead and it checks every xhtml:link annotation by cross-referencing the entries against each other, with no per-page fetch. It also flags the two things that make a correct set get ignored anyway: a noindex on the page, and a canonical pointing somewhere else. Exit code 1 in CI when an error appears.
Free · MIT-licensed · README checked September 2026
Install and run
# one-off, nothing installed (Node 18+):
npx github:CrawlCove/crawlcove-hreflang-checker https://www.example.com/en-gb/
# global command, from the release tarball:
npm install -g https://github.com/CrawlCove/crawlcove-hreflang-checker/archive/refs/tags/v1.0.0.tar.gz
hreflang-checker --version
Options
hreflang-checker <url> [options]
--sitemap treat the URL as a sitemap (auto-detected for URLs ending in .xml)
--max-alternates <n> alternates fetched for the return-tag check in page mode (default 20)
--max-urls <n> <url> entries read in sitemap mode (default 500)
--timeout <ms> per-request timeout (default 10000)
--user-agent <ua> User-Agent header to send
--json JSON output
--fail-on <level> error (default), warning, none
The README in the repo is the authoritative reference; the commands above are copied from it as of September 2026. If they disagree, the README is newer.
What it checks
- invalid-code and suspicious-code: en_US with an underscore, en-uk (the United Kingdom is gb), english, or uk on its own, which is Ukrainian.
- missing-self-reference and missing-x-default: every page in a cluster must list itself, and without x-default unmatched visitors get whichever version Google picks.
- missing-return-tag: page mode fetches up to 20 distinct alternates, four at a time, and reports each one whose own tags do not point back. One-way tags are dropped by Google.
- alternate-unreachable and alternate-redirects: an alternate that errors cannot be indexed, and a redirecting one may not carry the return tag.
- noindex and canonical-conflict: hreflang on a noindexed page, or on a page whose canonical points elsewhere, is disregarded however correct the tags are.
- Sitemap mode: relative hrefs, duplicate codes, entries whose alternates are not themselves listed, and a sitemap index followed into its first five children.
Limits worth knowing
- Page mode stops fetching alternates at the --max-alternates cap and says so with an alternates-truncated warning; raise the cap for a large cluster.
- Sitemap mode confirms return tags only for alternates that are themselves url entries in the same sitemap; anything else is a not-in-sitemap warning to check in page mode.
- It checks one page's cluster or one sitemap per run, not a whole site.
Works with Crawl Cove
Hreflang checker CLI covers the checks it lists above. The desktop app runs the full site audit: every page, every finding ranked by impact, history over time and Search Console data alongside. See the desktop checker or compare the plans.
Frequently asked questions
- How is this different from the browser hreflang checker?
- Same checks, different place. The browser version at /tools/hreflang-checker is for one URL or one sitemap you have in front of you. The CLI takes the same input in a script, prints machine-readable JSON, and returns an exit code, so a deploy can fail when a localised page loses its return tags.
- Where does it read hreflang from?
- From the three places Google accepts it: link rel="alternate" hreflang tags in the HTML head, the HTTP Link response header, and xhtml:link annotations inside an XML sitemap. Each reported tag is labelled with its source, so a tag declared twice in two places is visible as such.
- Why does it fetch the other pages?
- Because hreflang is only honoured when both pages reference each other. Reading one page tells you what it claims; fetching each alternate tells you whether the claim is reciprocated. In sitemap mode no fetch is needed, since a sitemap has to declare the whole cluster on every entry and the entries can be checked against one another.
- The tags are all correct and Google still ignores them. Why?
- The two usual causes are a noindex on the page, which means it is never served from search, and a canonical pointing at a different URL, since Google reads hreflang from the canonical page only. This tool reports both as errors. If neither applies, check that every alternate is itself indexable.
- Can it check a whole site's hreflang?
- It checks one page's cluster or one sitemap per run. To audit every localised page on a site, including alternates that point at non-indexable pages, crawl it with Crawl Cove, which builds the whole cluster as it goes and tracks it over time.
Stop guessing.
Start fixing.
Crawl Cove runs on your machine, connects to your real ranking data, and tells you exactly what to fix first. No per-feature paywalls, no spreadsheets, no guesswork.
28 days risk-free · No card required