'Gatsby i18n: How to avoid creating pages for all locales?
I use gatsby-plugin-react-i18next and WP Polylang for multilanguage site with headless WordPress + gatsby.
The logic is that for pages that haven't translate version in WP Admin I just redirect user to home.
I see that in build I have static files for all locales and all posts event that post haven't translate in WP admin.
How I can skip build static files for some posts that haven't translates?
Solution 1:[1]
I think your only option is to add them manually in the gatsby-plugin-react-i18next or include them into a regular expression using matchPath and excludeLanguages:
pages: [
{
matchPath: '/:lang?/blog/:uid',
getLanguageFromPath: true,
excludeLanguages: ['es']
},
]
Note: you can add several instances in the array of pages.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ferran Buireu |
