New Hubspot Blog Search: How to manage more languages?
SOLVE
I wrote a post here on this forum discussing how to create a custom blog search. I'm not sure if that would help at all, if anything it would need to be expanded to account for different language versions, but it definitely does a decent job for a blog search. not a full site search though. Here is a blog post I wrote about it as well.
New Hubspot Blog Search: How to manage more languages?
SOLVE
I know this post is pretty old, but for everyone who struggles with this topic, I want to share my solution.
First of all my case:
I want to implement a multi-language search-results-page for our website. The primary language is English, so the URL for those pages does not have any language identifier in the slug. www.example.com/some-page
The secundary language is German, so the URL needs the language identifier in the slug.
On several locations of the website we use hard coded phrases, which are translated with the help of the "html_lang" variable provided by HubSpot. To manage those hard coded phrases, I created a separate file called "lang.html", which holds those phrases in different languages like this:
This works pretty well on our entire website, because now I only need to insert this file in my custom coded base template and then call a translation by ...
{{ lang['search results'][html_lang] }}
BUT this won't work on the search results page, since HubSpot does not provide to create a multi-lanugage version for those pages. So I needed to find a workaround. Therefore I setup the site search so it does contain the "language" param in the URL. So when I send a search query on the German website, I'll get redirected to the URL www.example.com/search-results?term=something&language=de.
Pretty nice, since I now just need a little bit of HubL to manipulate the page content of the search results page.
First I need this URL somehow and I found the variable "request.path_and_query", which works on every HubSpot Page. The rest is simple. Let me show you my code...
{# Get language from URL ('...&language=en') #}
{# First, store URL params into a list, like ['term=something', 'language=de'] #}
{% set url_params = request.path_and_query|regex_replace("(.*)\\?", '')|split('&') %}
{# Next, attach needed params to a dict, to make it usable later, like {'language': 'de'} #}
{# Feel free to add more params if needed #}
{% set params = {} %}
{% for param in url_params %}
{% set key_value = param|split('=')%}
{% if key_value[0] == 'language' %}
{% do params.update({
'language': key_value[1]
}) %}
{% endif %}
{% endfor %}
{# Finally, set language for search results page from params dict created earlier #}
{% if params.language %}
{% set html_lang = params.language %}
{% endif %}
Super nice, now I can use the "html_lang" variable again for things like "Search Results" which should be translated to "Suchergebnisse" by calling my language dictionary via ...
<h1>{{ lang['search results'][html_lang] }}</h1>
{# English Search Results #}
<h1>Search Results</h1>
{# German Search Results #}
<h1>Suchergebnisse</h1>
I've been experiecing the same problem with my blogs in English and German in Hubspot.
I already managed to fix the problem of showing only the content in the language of the page the user is in the moment - German content for who's in a German page using the search bar - with some custom HTML + Hubl and a custom JavaScript function (you can see the code in my answer here).
However, I haven't fixed yet the problem of a custom Search Results Page. I asked the Hubspot Support for some help in it, but this was their answer: "Since the Search Results page is still a newer feature, multiple language is not available because you can only select one default search results page.".
My idea now is to create two Search Results Pages (one in each language) and run a JS function in the "data-search-path" part of HTML + Hubl in a custom Site Search Results.
May 15, 201810:52 AM - edited May 15, 201810:53 AM
Member | Platinum Partner
New Hubspot Blog Search: How to manage more languages?
SOLVE
Hi Jsum
Thanks for your reply!
Few weeks ago Hubspot relased a beta Blog Search Engine named Site Search.
This is the email i received after asked for it to my agency's colleagues:
"Hello!
You are receiving this email because you now have access to the site search beta within your HubSpot portal. Site search allows you to easily index your content so your website visitors can search for exactly what they are looking for. You will be able to create a new Systems template for search, which you can manage within Content Settings. The beta also gives you access to two new modules: Search Field and Search Results. While we create knowledge documentation for this beta feature, please feel free to refer to this document
Also note that access to site search is reliant on you being part of the Design Manager Beta.
New Hubspot Blog Search: How to manage more languages?
SOLVE
That is new.
Considering that it is so new that the documentation for it is in a google doc, I would say that you are going to have a hard time finding someone who knows anything about it. I'm stay pretty up-to-date with Hubspot and I didn't even know this was a thing. You might consider reaching out to the team at Hubspot that works on this, maybe through your account rep, to have them flush the docs out a bit. Multi-language is most likely not yet a supported feature.
New Hubspot Blog Search: How to manage more languages?
SOLVE
I wrote a post here on this forum discussing how to create a custom blog search. I'm not sure if that would help at all, if anything it would need to be expanded to account for different language versions, but it definitely does a decent job for a blog search. not a full site search though. Here is a blog post I wrote about it as well.