CMS Development

RKhengar
Miembro

Redirect Search Results Based on User's Language Preference

resolver

Hello HubSpot Community,

 

I'm currently working on a project where I need to redirect search results based on the user's language preference. The goal is to ensure that users are shown search results that are relevant to their preferred language.

 

Here's a brief overview of my setup and requirements:

  1. Current Setup:

    • Platform: HubSpot
    • Customization: I've been working on customizing the search results page URLs.
  2. Requirements:

    • To provide some context, our website features a global search option accessible via the navigation bar (search icon). Our site supports multiple languages, including US , English(test.com), UK   English(test.com/en-gb), and Spanish (test.com/es), with the global search functionality available across all these versions.

      The issue we are encountering is that when a search is performed on the UK (test.com/en-gb) or Spanish(test.com/es)  site, the results are being redirected to the US(test.com)  site, regardless of the language used. You can see this behavior (test.com/search-results?term=test)

      Our goal is to ensure that search results are directed to the appropriate language-specific page. 

  3. Challenges:

    • We have tried with creating copy template of system page search result. But we are unable to select those template while creating web pages.
    • What’s the best approach to implement URL redirection based on this language preference?

I would greatly appreciate any guidance or examples on how to achieve this. If there are specific tools or techniques within HubSpot that can facilitate this, please let me know.

Thank you in advance for your help!

 

 

0 Me gusta
1 Soluciones aceptada
evaldas
Solución
Asesor destacado | Partner nivel Platinum
Asesor destacado | Partner nivel Platinum

Redirect Search Results Based on User's Language Preference

resolver

Hi @RKhengar,

 

At the moment, there can be only one search results page per domain. In order to get around this limitation, you can set up the rest of the search result pages as regular website pages that have a search results module in the template. 

 

Then, you would need to set up the search input for each of your language variations to go to that particular search results page. This will require cloning the default search input module and making modifications.

 

For example, this is how the code would look for a search input that would go to your Spanish search results page (i.e. yourwebsite.com/es/search) :

 

<form action="/es/search">
...
<input type="hidden" name="language" value="es">
....
</form>

 

Hope this helps!


✔️ Did this post help answer your query? Help the community by marking it as a solution.

Ver la solución en mensaje original publicado

0 Me gusta
1 Respuesta 1
evaldas
Solución
Asesor destacado | Partner nivel Platinum
Asesor destacado | Partner nivel Platinum

Redirect Search Results Based on User's Language Preference

resolver

Hi @RKhengar,

 

At the moment, there can be only one search results page per domain. In order to get around this limitation, you can set up the rest of the search result pages as regular website pages that have a search results module in the template. 

 

Then, you would need to set up the search input for each of your language variations to go to that particular search results page. This will require cloning the default search input module and making modifications.

 

For example, this is how the code would look for a search input that would go to your Spanish search results page (i.e. yourwebsite.com/es/search) :

 

<form action="/es/search">
...
<input type="hidden" name="language" value="es">
....
</form>

 

Hope this helps!


✔️ Did this post help answer your query? Help the community by marking it as a solution.

0 Me gusta