seven
seven

Reputation: 1674

i18n deployment with SEO in mind for NextJS

I was tasked with implementing an i18n for the company website. At present we are using Netlify with @netlify/plugin-nextjs, and I hit the wall when submitting a PR when I got an error saying that

Error: i18n support is not compatible with next export.

I have read several topics here and a few articles and I found one smart workaround https://dev.to/adrai/static-html-export-with-i18n-compatibility-in-nextjs-8cd

And other suggestions were to move to Vercel. Is this the thing I should consider? We do not use getServerSIdeProps anywhere, the website is fully SSG so what is the benefit of the next export over the SSG approach? Is SEO better with the next export?

Next-translate seems to be building pages in development on every page change so perhaps it is possible to build a separate page for every translation without the need for such a burden?

I think moving to Vercel would be doable but should I do that? Would this allow me to deploy the translation while saving the SEO that next export gives? Or should I go with the custom solution above?

Thanks

Upvotes: 2

Views: 1739

Answers (1)

maxeth
maxeth

Reputation: 1515

With next export you can generate static HTML pages (SSG) that can be served easily from any server of your choice, but this way you won't be able to use all of the features listed on this page: https://nextjs.org/docs/advanced-features/static-html-export#unsupported-features

And other suggestions were to move to Vercel. Is this the thing I should consider? We do not use getServerSIdeProps anywhere, the website is fully SSG so what is the benefit of the next export over the SSG approach? Is SEO better with the next export?

When deploying to Vercel or Netlify you still have all the SEO benefits of statically generated pages (Either through Automatic Static Optimization or manual usage of getStaticProps) and full access to all Next features listed in the link above (including i18n). Hence, if you have static pages, next-export has no SEO benefits over deploying on Vercel/Netlify, as in both cases you will serve pre-rendered pages to users, but next-export just gives you better flexibility when it comes to deployment.

Next-translate seems to be building pages in development on every page change so perhaps it is possible to build a separate page for every translation without the need for such a burden?

As you mentioned, that's exactly what the example you linked above achieves: It pre-renders every page for every locale you have, which is also exactly what you'd get when deploying a Next app with a i18n package like next-translate or next-i18next on Vercel or Netlify.

I think moving to Vercel would be doable but should I do that? Would this allow me to deploy the translation while saving the SEO that next export gives? Or should I go with the custom solution above?

If you can, you should deploy on Vercel or Netlify to save a lot of time and get all the features like i18n out of the box. But, the example you provided above also makes i18n work with next-export so if you have a plain, static website that requires no other custom Next features like routing, middleware or Image optimization, it will surely work too if you don't want to deploy on Vercel/Netlify.

Upvotes: 1

Related Questions