seo_hreflang_generator
Generate and validate hreflang annotations for international SEO from language-and-URL entries, outputting HTML, sitemap, or HTTP-header formats.
Instructions
Hreflang Generator (Build International SEO Alternate-Language Link Tags). Generate and validate rel="alternate" hreflang annotations for international SEO from a list of language/region-to-URL entries. The 'operation' field selects the mode. 'generate' serializes the entries into three formats at once (HTML tags for , xhtml:link tags for a sitemap block, and RFC 8288 Link: HTTP-header lines), XML-escaping every href and emitting warnings for invalid BCP 47 codes, non-absolute URLs, duplicates, missing x-default, and reciprocity. 'validateCode' checks a single BCP 47 tag and returns its normalized form plus parsed language/script/region subtags. 'commonCodes' returns a curated 40+ entry catalogue of well-known codes (en, en-US, zh-Hans, x-default). Use this for standalone alternate-language tags; use seo_sitemap_generator when you want the same alternates embedded in a full XML sitemap, or seo_meta_tag_generator for a complete meta block. Runs locally in a 5s-bounded Node process:
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| operation | Yes | "generate" builds hreflang tags from "entries"; "validateCode" checks one "code"; "commonCodes" lists the curated catalogue. Defaults to generate. | generate |
| entries | No | Language-variant entries for operation "generate" (required, min 1 valid entry). Entries missing hreflang or href are skipped with a warning. | |
| format | No | Output serialization for operation "generate". html = <link> tags; sitemap = <xhtml:link> tags; http-header = RFC 8288 Link: lines. Defaults to html. | html |
| includeXDefault | No | When true, append an x-default entry (using xDefaultHref or the first entry's href) unless one is already present. | |
| xDefaultHref | No | Absolute URL for the appended x-default entry when includeXDefault is true; ignored otherwise. Non-absolute values warn. | |
| code | No | Single BCP 47 tag to validate for operation "validateCode" (required for that operation), e.g. zh-Hant-TW. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| success | No | True when the operation succeeded. | |
| operation | No | Echo of the operation performed (generate, validateCode, or commonCodes). | |
| result | No | Operation-specific payload. |