Rule: alternates-hreflang
Hreflang tags tell search engines about the language and regional targeting of your pages. If you have multiple language versions of a page (/en/about, /fr/about), hreflang links them so Google shows the right version to each user. This rule currently reports hreflang information found on the page but always passes — it's informational, not prescriptive.
What it checks
Indxel scans for <link rel="alternate" hreflang="..."> tags in the HTML head. It reports what it finds (languages, region codes, URLs) but does not validate correctness. The rule always passes regardless of whether hreflang tags are present. It's an informational check included for completeness.
Thresholds
Always passes — informational only
Edge cases
This rule is intentionally non-prescriptive. Not every site needs hreflang. It only applies to multi-language sites.
Hreflang x-default: the special value hreflang="x-default" indicates the fallback URL for users whose language doesn't match any specified alternate. Indxel reports this but doesn't require it.
Bidirectional requirement: if page A hreflang-links to page B, page B must also hreflang-link back to page A. Indxel currently does not validate this bidirectionality (it would require crawling both pages).
In Next.js, hreflang is set via alternates.languages in metadata. Example: alternates: { languages: { en: '/en/about', fr: '/fr/about' } }.
Configuration
// indxel.config.ts
import { defineSEO } from "indxel";
export default defineSEO({
rules: {
"alternates-hreflang": true, // enabled by default
},
});
// Set hreflang in Next.js metadata:
export const metadata = {
alternates: {
canonical: "https://example.com/about",
languages: {
en: "https://example.com/en/about",
fr: "https://example.com/fr/about",
"x-default": "https://example.com/about",
},
},
};Frequently asked questions
Why does this rule always pass?
Hreflang is only relevant for multi-language sites. Requiring it on all sites would create false positives for the vast majority of English-only sites. The rule is informational — it reports what it finds so you can verify correctness manually.
Should I add hreflang if my site is English-only?
If your site is available in only one language, you don't need hreflang tags. The canonical URL is sufficient. Hreflang is only needed when you have the same content in multiple languages or regional variations.
Will this rule become stricter in the future?
Possibly. Future versions may validate hreflang format (e.g., correct language codes), bidirectional links, and consistency across pages. For now, it's informational only.