hreflang Alternate Language Pairs
Checks supplied hreflang/href pairs for nonempty values and repeated language labels ignoring ASCII case. It does not validate BCP 47 registry membership, URL syntax, reciprocal links or search-engine selection.
Description
Alternate-language links pair a language label with a destination for another representation.
Alternate-language links pair a language label with a destination for another representation. Local completeness and duplicate labels can be checked before validating the wider alternate-link cluster.1
The tool returns emptyAt, duplicateLanguageAt, locallyComplete. The fields describe the supplied local pattern or effective state, or contain the formatted markup shown below.
When to use hreflang Alternate Language Pairs
Use this for the following task: Checks supplied hreflang/href pairs for nonempty values and repeated language labels ignoring ASCII case. It does not validate BCP 47 registry membership, URL syntax, reciprocal links or search-engine selection. Provide the requested local fields extracted from the relevant element or attribute.
How to use hreflang Alternate Language Pairs and understand its results
- Prepare the parsed element names, attribute values or direct element-child lists requested below. Keep attribute presence separate from its value.
- Enter languages, hrefs according to the field table, then run the tool.
- Read emptyAt, duplicateLanguageAt, locallyComplete. Check the effective state, recognized-token flags or generated markup against the rules below.
- Correct any reported local mismatch and check the resulting markup in its intended document and browser context.
| Input field | Meaning | Value type and bounds | Requirement |
|---|---|---|---|
| languages | Languages | list of string; minimum entries 0; maximum entries 10000; each entry: maximum text length 10000 | Required |
| hrefs | Hrefs | list of string; minimum entries 0; maximum entries 10000; each entry: maximum text length 10000 | Required |
Provide equal-length language and href lists. Find whitespace-only values and indexes of repeated labels, using untrimmed ASCII-case-folded language text as the duplicate key.
locallyComplete = no empty pair AND no repeated ASCII-case-folded language label The symbols and boundary conditions refer to the supplied fields and the implementation described above.
| Output field | Meaning | Value type |
|---|---|---|
| emptyAt | Empty At | list of integer |
| duplicateLanguageAt | Duplicate Language At | list of integer |
| locallyComplete | Locally Complete | boolean |
{
"input": {
"languages": [
"en",
"fr",
"EN"
],
"hrefs": [
"/en",
"/fr",
"/en-us"
]
},
"output": {
"emptyAt": [],
"duplicateLanguageAt": [
2
],
"locallyComplete": false
}
} Limitations and assumptions
BCP 47 membership, URL syntax, reciprocal links and search-engine selection are not checked. Empty lists pass, and whitespace surrounding a label is not normalized.
The tool does not fetch a page, run a browser or validate an entire HTML document. Malformed tool requests produce input errors; valid requests can still report unrecognized values or failed local checks.
Alternative or Complementary methods
Choose link rel=alternate Feed Type Lookup when you need its operation: Builds link rel=alternate feed metadata for RSS or Atom with the standard media type and an escaped caller-supplied href. URL fetching and feed document validation are separate. Choose Canonical link rel Check for the complementary operation: Checks the canonical relation and a nonempty parsed href. Relative href values are accepted; this does not establish URL validity or canonical selection by search engines.
Background reference: HTML Standard: hreflang Alternate Language Pairs.
References
Similar or alternative tools
- link rel=alternate Feed Type Lookup
Builds link rel=alternate feed metadata for RSS or Atom with the standard media type and an escaped caller-supplied href. URL fetching and feed document validation are separate.
- Canonical link rel Check
Checks the canonical relation and a nonempty parsed href. Relative href values are accepted; this does not establish URL validity or canonical selection by search engines.