No Slug Home Page Redirect to Language Specific Home Page

pcharette
Member

Hi everyone,

I have a language specific issue for a customer whose website is on HubSpot COS.

I need the home page without slug to redirect to either the /fr homepage or /en homepage, depending on the language setting in the user's cookie.

Right now, I only used a 301 redirect from no slug to /fr (main language), but I would really like the website to recognize the user's language for direct traffic coming from the homepage without slug.

Normally, we used to deal with that on the server side, but now that the site is on HubSpot, we don't have access anymore.

So is there a simple script I could put in the header of the no slug homepage to detect cookie language? Or should I do it differently?

Thanks guys !

0 Upvotes
3 Replies 3
Derek_Gervais
HubSpot Employee

Hi @pcharette,

It's not currently possible (or at least, not reliable) to include client side Javascript that detects a user's preferred language, since that information is primarily passed in the Accept-Language header. Currently, you can target smart content based on preferred language, but otherwise it's not accessible client-side. I've included a couple resources that might be helpful below:

0 Upvotes
SimonS
Top Contributor | Platinum Partner

Hi @Derek_Gervais,

 

Do you know how to combine smart content with the language switcher? We've got a client who also wants to deliver EN content to all visitors outside The Netherlands. At least at their homepage. At the same time they want the visitor to be able to switch the language on other pages.

 

What happens when someone visits the homepage and based on browser language or country (by IP address) sees the EN version and navigates to another page. Does she still sees EN content or will it be Dutch (as we speak/read in The Netherlands)? I think that can be managed by using different menu's as smart content as well. But I'm guessing here...

 

Cheers, Simon

0 Upvotes
Gabvo
Participant

@Derek_Gervais "not reliable" is better than nothing. Where can we do it?

0 Upvotes