How to exclude from translation all pages except specific one(s)?
In this article, you'll find how to exclude every page from translation except specific ones.
Go to your Weglot Dashboard > Projects > Settings > Translation Exclusions:
There, you'll normally be able to add the pages you would like to exclude:
Then, you will find several ways to exclude all pages except specific ones:
1) By directly selecting what the URL shouldn't contain
For this, you can click on "Add Rule" and select one of these options:
- "Is not exactly": This will exclude all the URLs with paths other than the one you added.
- "Does not start with": This will exclude all the URLs that don't start with the path you add.
- "Does not end with": This will exclude all the URLs that don't end with the path you add.
- "Does not contain": This will exclude all the URLs that don't contain the path you add.
A little reminder: The Exclude URL section works with relative URLs. For example, if your page is www.mywebsite.com/mypage/, then /mypage/ is the relative URL.
For example, if you select "Is not exactly" and add the path "/my-page", this will exclude all URLs on your website, except "/my-page".
2) By using a regex rule
For this, you can click on "Add Rule" and select "Match regex"
There's a way to say "exclude everything except..". This is possible with regular expressions (RegEx).
Tips for the Exclude URL section with regular expressions (RegEx)
- Exclude everything except a specific page using its relative URL: ^(?!\/mypage\/$).*
- Exclude everything except the landing page: ^(?!\/$).*
- Exclude everything except a few specific pages: ^(?!\/$|\/shop\/$|\/categorie-produit\/$|\/produit\/$).*
- Exclude everything except everything that begins with /product/... ^(?!\/product\/).* (Meaning, without the "$")