QuiiBz / next-international

Type-safe internationalization (i18n) for Next.js
https://next-international.vercel.app
MIT License
1.26k stars 59 forks source link

Duplicate pages when using rewriteDefault #196

Closed DennieMello closed 11 months ago

DennieMello commented 11 months ago

Is your feature request related to a problem? Please describe. Now, when using the option in urlMappingStrategy: 'rewriteDefault', we have two duplicate pages for the default language with and without /en. This is not very good for both SEO and users.

Describe the solution you'd like It would be logical to redirect from all pages containing the default language in the url to pages without it.

gustaveWPM commented 11 months ago

I'm not sure we're really talking about duplicate pages/internal duplicate content.

The SSG only generates /fr/*, /en/*, /it/*, /.../* pages in my project, and it works well... (In fact, it works almost well: there is an another issue, way more concerning for SEO, that should be fixed soon, I hope. You can find more information about it here: https://github.com/QuiiBz/next-international/issues/190).

If you're annoyed that the /en/* URL doesn't redirect the user immediately upon visiting the website, you can also set up a 301 redirect, nope? (It will redirect as soon the user click on a <Link>. Dunno why it isn't done sooner).

I'm just afraid that redirecting from a /en/* page to a /* page will redirect to the last language stored on the user's side, though. Idk if that's the behaviour you want.

(I guess that en is your default language?)

DennieMello commented 11 months ago

I'm not sure we're really talking about duplicate pages/internal duplicate content.

The SSG only generates /fr/*, /en/*, /it/*, /.../* pages in my project, and it works well... (In fact, it works almost well: there is an another issue, way more concerning for SEO, that should be fixed soon, I hope. You can find more information about it here: #190).

If you're annoyed that the URL doesn't redirect the user immediately upon visiting the website, you can also set up a 301 redirect, nope?

I'm just afraid that redirecting from a /en/* page to a /* page will redirect to the last language stored on the user's side, though. Idk if that's the behaviour you want.

(I guess that en is your default language?)

Perhaps you have a different urlMappingStrategy value? With "rewriteDefault", pages with url /fr/, /en/..., are actually generated, but pages with defaultLocale are available both with and without locale specified. This leads to duplicate content.

301 redirect can be specified additionally in the middleware, but it seems to me that it would be more correct and safer to release this at the level of this module.

Are there any reasons why duplication of content may be necessary, both with and without the default locale prefix?

QuiiBz commented 11 months ago

Agree that when using rewriteDefault, the default locale shouldn't be reachable through a URL segment and should instead redirect to the correct URL. I've added this behavior in #204 and it will be released soon in #205