> For the complete documentation index, see [llms.txt](https://developers.weglot.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.weglot.com/cms/wordpress/use-cases/how-weglot-handles-link-translation-and-exclusions.md).

# How Weglot handles link translation and exclusions

Weglot automatically translates both the **URL** of a link and its **text label**, based on the current language. This page explains the default behavior and how to control each part independently.

### Default behavior

Take this link:

```html
<a id="my-link" href="https://weglot.com" title="Weglot website">this is my link label</a>
```

On the French version of your site, Weglot outputs:

```html
<a id="my-link" href="https://weglot.com/fr/" title="Weglot website">ceci est le label de mon lien</a>
```

* The **label** (`this is my link label`) is translated.
* The **URL** is automatically adapted to include the language code (`/fr/`).

### Excluding a link from translation

If you exclude the link (for example with the `#my-link` selector in your exclusion rules), the **label stays untranslated** — but the **URL is still adapted** to include the language code:

```html
<a id="my-link" href="https://weglot.com/fr/" title="Weglot website">this is my link label</a>
```

This is expected: excluding a block prevents its text from being translated, while link URLs are rewritten by a separate mechanism.

### Keep the URL untranslated but still translate the label

Sometimes you want the opposite: keep the link URL exactly as-is (no language code) while still translating the label. Add the `wg-excluded-link` attribute to the tag:

```html
<a id="my-link" href="https://weglot.com" title="Weglot website" wg-excluded-link>this is my link label</a>
```

Result in French:

```html
<a id="my-link" href="https://weglot.com" title="Weglot website">ceci est le label de mon lien</a>
```

* The URL stays `https://weglot.com` (no `/fr/`).
* The label is still translated.

Use this when a specific URL must stay untouched (an external tracking link, a file, a third-party endpoint…) while still giving your visitors a localized link text.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.weglot.com/cms/wordpress/use-cases/how-weglot-handles-link-translation-and-exclusions.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
