Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

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:

<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:

<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/).

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:

<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:

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

Result in French:

  • 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.

Last updated