# Hreflang tag generator

> Generate hreflang link tags for the language and country versions of a page, with x-default. Validates codes and URLs as you go. Free.

Free tool by Orkosi. Page: https://orkosi.com/tools/hreflang-generator

If your page exists in several languages, hreflang tells search engines which one to show to whom. List each version and get the tags every one of them must carry.

1. Write one line per version: the language code, a space, the URL.
2. Add the page for everyone else as x-default.
3. Press Generate and paste the same block on every listed page.

## Input

| Field | Type | Required | What it is |
| --- | --- | --- | --- |
| `pages` | text | yes | Language versions. |
| `x_default_url` | text | no | x-default URL. |

## Example

Input:

```json
{
  "pages": "en-GB https://example.com/uk/pricing\nen-US https://example.com/us/pricing\npt-PT https://example.com/pt/precos",
  "x_default_url": "https://example.com/pricing"
}
```

Result:

```json
{
  "html": "<link rel=\"alternate\" hreflang=\"en-GB\" href=\"https://example.com/uk/pricing\">\n<link rel=\"alternate\" hreflang=\"en-US\" href=\"https://example.com/us/pricing\">\n<link rel=\"alternate\" hreflang=\"pt-PT\" href=\"https://example.com/pt/precos\">\n<link rel=\"alternate\" hreflang=\"x-default\" href=\"https://example.com/pricing\">",
  "languages": 3,
  "warnings": [
    "Paste the same block on every listed page."
  ]
}
```

## Run it

It needs a free Orkosi account, nothing else. No credits are used.

- **A person**: open the page, enter an e-mail once, use the tool.
- **Claude or ChatGPT**: add the Orkosi connector `https://orkosi.com/api/v1/public/mcp` and sign in, or create the free account on the sign-in page. Then call `orkosi_run_free_tool` with `{ "tool": "hreflang-generator", "input": { … } }`.
- **Any agent or program that can make an HTTP request**:

  1. Once, create the account: `POST https://orkosi.com/api/v1/public/signup` with `{ "name": "…", "email": "…", "terms_accepted": true }` and no key. Ask the person for the e-mail and their agreement to the terms first. The answer carries `data.api_key`, shown once.
  2. Run the tool:

```bash
curl -X POST https://orkosi.com/api/v1/public/tools/hreflang-generator/run \
  -H "Authorization: Bearer $ORKOSI_API_KEY" -H "Content-Type: application/json" \
  -d '{"input":{"pages":"en-GB https://example.com/uk/pricing\nen-US https://example.com/us/pricing\npt-PT https://example.com/pt/precos","x_default_url":"https://example.com/pricing"}}'
```

The answer is `{ "data": { "tool": "…", "result": { … } } }`. A call without a key is answered 401 with the signup steps as data.

## Questions

**Which codes do I use?**

A two-letter language (en, pt, de), optionally followed by a country (en-GB, pt-BR). The country alone is not valid.

**What is x-default?**

The page for visitors whose language you do not cover, usually the English version or a language picker.

**Why must every page list all the others?**

Hreflang only counts when it is mutual. If the German page does not link back to the English one, both tags are ignored.

All free tools: https://orkosi.com/tools.md
