Hreflang Check

Checks hreflang tags or a sitemap against Google's rules, so missing return links or bad codes don't get the whole set ignored.

StopsHelps catch hreflang tags Google would ignore

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/hreflang-check.json

The files land in your project. They're yours to edit.

Usage

hreflang-check-usage.tsx
import { HreflangCheck } from "@/components/ui/hreflang-check"

return <HreflangCheck defaultValue={pricingPages} rows={7} />

What it catches

  • Missing or near-miss return links between versions
  • Codes Google doesn't support: en-UK, es-419, region-only codes
  • Relative or protocol-relative URLs
  • Missing self-reference or x-default
  • A canonical pointing at another language's page

Props

HreflangCheck props
PropTypeDefault
value

Controlled text: <link> tags (HTML head or sitemap xhtml:link), grouped under a URL line or <loc> per page.

string—
defaultValue

Initial text when uncontrolled.

string""
onValueChange

Called with the new text on every edit or fix.

(value: string) => void—
pageUrl

URL of the page when only one page's tags are pasted without a URL line.

string—
label

Visible label; shorthand for `messages.label`.

string—
messages

Every visible string. `{detail}`, `{to}`, `{fix}`, `{url}`, `{count}` are filled in.

Partial<HreflangCheckMessages>—

* required. Also accepts the native props of <textarea> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Text area has a label, aria-invalid when errors exist, and is described by the hint and status
  • Status uses role=status; icons are aria-hidden
  • The link grid is a table with row and column headers and a text description in each cell
  • Focus returns to a nearby button after a fix

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

  • Checks only what you paste; it does not crawl live pages or HTTP Link headers
  • Follows Google's documented rules; other search engines may differ
  • Can't tell whether page content actually matches the declared language

Rules

Rules last verified:

Informational; check the official source. Confirmed: return links, self-reference, fully-qualified URLs, ISO 639-1 + ISO 3166-1 alpha-2 (es-419 unsupported, UK not a valid region), optional ISO 15924 script, x-default. Copied components don't update themselves, so re-check after rule changes (see updating a component).

What it stops

Helps catch hreflang tags Google would ignore

Also known as

hreflang · seo · i18n · sitemap · canonical · multilingual · search console · x-default

Field type

Dependencies

Pairs well with