Translate routes for SEO
Unanswered
Bombay posted this in #help-forum
BombayOP
Hello,
I am looking for a way to translate routes to get better SEO score for all the country and the languages we support. For example:
EN: /category/subcategory/abc
becomes
IT: /categoria/sottocategoria/abc
but they all need to point to the same page (the translation of the content is handled with a CMS). I've digged into previous post but it seems there is no easy way to achieve this result. Someone hardcoded all the possible paths but it would sadomasochism to do it in our case with six languages and 3 or 4 levels of routing. Can you provide some suggestions?
I am looking for a way to translate routes to get better SEO score for all the country and the languages we support. For example:
EN: /category/subcategory/abc
becomes
IT: /categoria/sottocategoria/abc
but they all need to point to the same page (the translation of the content is handled with a CMS). I've digged into previous post but it seems there is no easy way to achieve this result. Someone hardcoded all the possible paths but it would sadomasochism to do it in our case with six languages and 3 or 4 levels of routing. Can you provide some suggestions?
3 Replies
@Bombay Hello,
I am looking for a way to translate routes to get better SEO score for all the country and the languages we support. For example:
EN: /category/subcategory/abc
becomes
IT: /categoria/sottocategoria/abc
but they all need to point to the same page (the translation of the content is handled with a CMS). I've digged into previous post but it seems there is no easy way to achieve this result. Someone hardcoded all the possible paths but it would sadomasochism to do it in our case with six languages and 3 or 4 levels of routing. Can you provide some suggestions?
next-intl supports translated routes, see https://next-intl-docs.vercel.app/docs/routing/middleware#localizing-pathnames
@Bombay solved?
BombayOP
Nope, we are still fighting with NextJS to get some routes translated consistently.
Update: I tried to create a new project, a sort of minimal version of the actual project, and by following the linked guide I managed to translate routes correctly. The issue is that the actual project, which was developed initially by a 3rd party consultant, does not use next-intl but it uses a locale management system created from scratch which of course creates lot of troubles. The dude reads the locale from the url and then it then middleware.ts does his magic and decides which JSON file with translations to use. He passes those JSON dictionaries to all the components which need them.
Right now the URL translation works only when you change the language from a dropdown but when you go to the categories page and select (click a link with) a category the selected language and the translation do not match
Update: I tried to create a new project, a sort of minimal version of the actual project, and by following the linked guide I managed to translate routes correctly. The issue is that the actual project, which was developed initially by a 3rd party consultant, does not use next-intl but it uses a locale management system created from scratch which of course creates lot of troubles. The dude reads the locale from the url and then it then middleware.ts does his magic and decides which JSON file with translations to use. He passes those JSON dictionaries to all the components which need them.
Right now the URL translation works only when you change the language from a dropdown but when you go to the categories page and select (click a link with) a category the selected language and the translation do not match