How to exclude from translation all pages except specific one(s)?
In this article, you'll find how to exclude every page from the translation except for 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 "$")
How to import/export exclusion rules?
To import or export exclusions rules, you need to manage at least an Advanced plan (see our pricing page).
To access this feature, you need to go to the "Translation Exclusions" page on your Weglot dashboard and use the "Actions" buttons:
And choose to do an Import or an Export:
Please note that you can import only CSV files, with a maximum of 500 exclusion rules and the files need to fit a specific structure. For the block exclusion rules, you can download this example file and for the URL exclusions, you can download this example file.
It is important not to modify the headers/the structure of the file because the import will not work as intended if the headers are modified.
To do an import, you can drag the file or click on the "Add" button.
Once the file is added, just click on "Next" and it will be imported.