[gatsby-theme-i18n] Create language detection page "/" for prefixDefault=true #114
Unanswered
javiertury
asked this question in
Ideas
Replies: 1 comment
-
I would also really like to see a solution for this. Any news? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
prefixDefault=true
prepends the locale to all URLs. This is nice feature but breaks the/
page, trying to accesshttp://localhost:8000/
returns a 404.The page
src/pages/index.tsx
is working as intended, it's served at/<locale>
. My objective is to create a language agnostic index page (/
) that detects the browser locale and redirect the user tohttp://localhost:8000/<locale>/
. However I'm not sure what is the right approach.I digged into the code of this theme and implemented a workaround. A page for language detection is added in
gatsby-node.js
and tricks gatsby-theme-i18n to ignore it.This is clearly not a good long term solution, and neither is to hardcode a
createRedirect
.Could theme options be extended to specify a unprefixed index page?
EDIT: with gatsby 3 the workaround is not as effective. The client side router still loads the page, but there is no
public/index.html
page being generated and a 404 page is served instead which is visible for about 1-2 seconds.Beta Was this translation helpful? Give feedback.
All reactions