CMS Development

RiccardoADV
Member | Elite Partner
Member | Elite Partner

New Hubspot Blog Search: How to manage more languages?

SOLVE

Hi all


I was looking at the new Hubspot blog search and i understood how it works. 

However i currently manage a multi-language blog in the same domain whit this structure:

example.com

example.com/en

Question is: if the Search Results page is a system page it must be unique, so how can i create different Search Result Pages for the two blogs?

I solved the problem for 404 and 500 by using text in smart content modules but i don't think it will be a good solution in this case also.

Has somebody experienced the same issue?

Thanks all!

0 Upvotes
2 Accepted solutions
Jsum
Solution
Key Advisor

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.

 

Hope that helps.

View solution in original post

AJLaPorte_diagr
Solution
Key Advisor

New Hubspot Blog Search: How to manage more languages?

SOLVE

Hi @RiccardoADV,

 

You can try to use the query params like pathPrefix 

 

An example of this would be:
https://blog.wsol.com/search?term=hubspot&pathPrefix=the

this returns results on the site with the term of Hubspot and who's url starts with "the" like:

https://blog.wsol.com/the-value-of-hubspot-certifications-infographic

 

So you could essentially have the search with:

example.com/search?term=SearchTerm&pathPrefix=en/

 

Hopefully, this helps point you in the right direction.

-AJ

View solution in original post

0 Upvotes
10 Replies 10
FabianRichter
Contributor

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.

www.example.com/de/some-page

 

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:

 

 

{
  ...
  "search results": {
    "en": "Search Results",
    "de": "Suchergebnisse"
  }
  ...
}

 

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>

 

 

If you found this helpful, give it a thumbs up.

 

Best,
Fabian

0 Upvotes
karinasonaglio
Contributor

New Hubspot Blog Search: How to manage more languages?

SOLVE

Hi @RiccardoADV,

 

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.

<div class="hs-search-results__pagination" data-search-path="{{ site_settings.content_search_results_page_path }}">

Let's see if this works.

 

I hope this helps somehow,

Karina Sonaglio

0 Upvotes
KLSutton
Participant

New Hubspot Blog Search: How to manage more languages?

SOLVE

@karinasonaglio - Did it work? 

0 Upvotes
karinasonaglio
Contributor

New Hubspot Blog Search: How to manage more languages?

SOLVE

Unfortunately I didn't have much time to continue with it at that time, so for now the answer is no 😕

0 Upvotes
AJLaPorte_diagr
Solution
Key Advisor

New Hubspot Blog Search: How to manage more languages?

SOLVE

Hi @RiccardoADV,

 

You can try to use the query params like pathPrefix 

 

An example of this would be:
https://blog.wsol.com/search?term=hubspot&pathPrefix=the

this returns results on the site with the term of Hubspot and who's url starts with "the" like:

https://blog.wsol.com/the-value-of-hubspot-certifications-infographic

 

So you could essentially have the search with:

example.com/search?term=SearchTerm&pathPrefix=en/

 

Hopefully, this helps point you in the right direction.

-AJ

0 Upvotes
Jsum
Key Advisor

New Hubspot Blog Search: How to manage more languages?

SOLVE

What blog search are you referencing?

0 Upvotes
RiccardoADV
Member | Elite Partner
Member | Elite 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.

 

Best,

Alex"

 

>Site Search documentation here

Hope it was useful!
 

0 Upvotes
Jsum
Key Advisor

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.

0 Upvotes
RiccardoADV
Member | Elite Partner
Member | Elite Partner

New Hubspot Blog Search: How to manage more languages?

SOLVE

Ok

You're right i will try to reach direclty Hubpost support.

However is not the first time that there are troubles with similar features, like for example other System Pages.

It could be easier if the matching system will be on blogs, not on subdomain.

I hope that some "Big Fish" from Hubspot will read this thread 🙂

Thanks Jsum and have a nice day!

0 Upvotes
Jsum
Solution
Key Advisor

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.

 

Hope that helps.