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