2

I'm working on a gatsby based multilingual website. Each translation has its own root based on the language code. For example:

Blog

/en/blog
/pl/blog
/de/blog

Contact

/en/contact
/pl/kontakt
/de/kontakt

But with this design, there is no such thing as a natural "root" for the domain. There is at least tree different roots:

example.com/en
example.com/pl
example.com/de

I think it would be very undesirable to return 404 on example.com. So I've decided to do something like that:

const Redirect = (props: any) => {
  useEffect(() => {
    const detected = detectLocale();
    const newUrl = `/${detected}${props.path}`;
    navigate(newUrl, { replace: true });
  }, []);

  return <></>;
};

And this redirect component is attached to /

However, with this approach, there is an empty page under example.com, which exists only to redirect users.

Would it impact SEO? Is there any better approach?

1 Answer 1

3

I have a similar setup and asked a similar question here: localized-start-page

  1. You might want to define one default language and allow the user to change the language. An alternate solution would be to use redirection based on the ip location. See e.g. here: geo-ip-location (I have to admit I have no experience with that).
  2. The root domain can redirect or rewrite to your default language start page.
  3. You can (and should) define language tags as recommended by google here: Tell Google about localized versions of your page E.g. This tags should go in the header section of each web page.
  4. You should also use the canonical tags.

This is as far as I collected the info together. Maybe somebody else can help fill in any still missing pieces.

4
  • Thank you for your suggestions. I would definitely prefer to redirect users based on IP or accepted language header. My only concern here is that example.com will be an empty page with just a javascript redirection. And it might be harmful from SEO point of view. Commented Mar 8, 2023 at 17:41
  • My point 2 addresses that point. It is probably better to use .htaccess with a rewriterule
    – Peter206
    Commented Mar 8, 2023 at 21:35
  • so in that case example.com will always redirect all users to example.com/en ? Commented Mar 9, 2023 at 8:59
  • This is how I made it, which is enough for my needs. But it is possible to make it more sophisticated, to switch by country. This is discussed e.g. here: stackoverflow.com/questions/19648241/…
    – Peter206
    Commented Mar 9, 2023 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.