Redirect Search Results Based on User's Language Preference
lösung
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:
Current Setup:
Platform: HubSpot
Customization: I've been working on customizing the search results page URLs.
Requirements:
To provide some context, our website features a global search option accessible via the navigation bar (search icon). Our site supports multiple languages, includingUS , English(test.com),UK English(test.com/en-gb), andSpanish (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 theUK (test.com/en-gb)orSpanish(test.com/es) site, the results are being redirected to theUS(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.
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.
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) :
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) :