lib
lib copied to clipboard
SEO friendly default locale routes
Wondering if this project will be able to autogenerate routes like @nuxtjs/i18n ? And also support that the default locale will not have a prefix. The current locale-router example does not support removing prefix for the default locale.
If it is not possible autogenerate the routes, how could I make the default locale not have prefix with the current solution? Maybe duplicate all pages in [lang] and move it directly in pages?
I think it might work using hooks.js
… maybe replacing this redirect and serving the appropriate language mutation instead. But not tested yet..
As pointed out in #77 this should be the default approach for the locale-router
example because of SEO…
Ah yes without this locale-router
is not feasible from a SEO perspective.
Sorry for the duplicate.
Also seems to switch multiple times
User hits "/"
and gets redirected to "/en/"
then redirected again to "/en"

Hmmm been playing around with the hook, but can't get it to work properly.. would be such a nice thing to have 😅
Agreed, I also tried with no success of far, but I think I’m close..)
Ok, have it... https://github.com/sveltekit-i18n/lib/pull/79/files
I'm not sure if it should also redirect the /defaultLocale/page
back to /page
or not...? Also nav links within the site now points to /$locale/page
which should be probably fixed for the default locale as well...
Works well, I think for SEO purposes the / page
and /defaultLocale/page
will act as duplicates and crawlers will be able to find the links on site, so would probably be best to have only /
as default?
Ok worked locally but can't access when published, doesn't get out of pending state.
https://629259c0302e9824c3b26832--testlocale.netlify.app/
If u add /en it goes through. But dynamic routes, in this case [post] is confused, I believe 🤔 - /sv/blog/post
becomes /blog/post
ok, netlify done https://locale-router.netlify.app unfortunately the workaround is a bit hacky (or non-elegant) – i'd rather use something like:
return resolve(MODIFIED_EVENT)
but still can't figure out how to modify the original event to fetch /locale/page
route instead of the original (locale unprefixed) one...
my current solution is here: https://github.com/sveltekit-i18n/lib/pull/79/commits/d5c09d83d0d2737e3c9c5bd233a9c48552f1f20f