CMS Development

dimitreliasb
Colaborador

Anchor to search result

resolver

I have added the HS search module to a web page. I was wondering if we can make it more user friendly. For example if I have a very long page of resources and the user enters the keyword in the seach input and the index finds the correct page so I click on that result but then it takes me to the page but that page has 10,000 words so it can take the user a while to pinpoint where that result was on that page. 

Is there any way to set something like anchors so not only the result goes to the correct page, but also scrolls down to where it found the keyword? I am assuming java script can do this had the same issue?

0 Me gusta
2 Soluciones aceptadas
LMeert
Solución
Guía | Partner nivel Platinum
Guía | Partner nivel Platinum

Anchor to search result

resolver

Hi @dimitreliasb,

 

The solution you're looking for will indeed rely on javascript.

The buil-in search engine returns, along with each search result, the snippet of text best corresponding to the search input. (cf. documentation).

 

You could imagine adding the snippet as a query parameter on each of your search results.
And then have a javascript function running on page load that will do a search for the queried content, add an anchor and scroll automatically.

 

There's quite a bit of work, and on both pages (search results AND your regular page templates), but it is definitely doable.

 

Hope this helps,

Ludwig

Agence Mi4 - Data DrivenCTO @ Mi4
Hubspot Platinum Partner and Integration Expert

Passionate human, very curious about everything data and automation.

Any problem with Hubspot you need help solving ?

Let me know !

Ver la solución en mensaje original publicado

0 Me gusta
stefen
Solución
Asesor destacado | Partner
Asesor destacado | Partner

Anchor to search result

resolver

like @LMeert said, it will take a bit of javascript work but it is possible. I'd probably use a function that checks for search term query parameter that would then scroll to the first instance of that term in the main content of the page. 

Stefen Phelps, Community Champion, Kelp Web Developer

Ver la solución en mensaje original publicado

3 Respuestas 3
LMeert
Solución
Guía | Partner nivel Platinum
Guía | Partner nivel Platinum

Anchor to search result

resolver

Hi @dimitreliasb,

 

The solution you're looking for will indeed rely on javascript.

The buil-in search engine returns, along with each search result, the snippet of text best corresponding to the search input. (cf. documentation).

 

You could imagine adding the snippet as a query parameter on each of your search results.
And then have a javascript function running on page load that will do a search for the queried content, add an anchor and scroll automatically.

 

There's quite a bit of work, and on both pages (search results AND your regular page templates), but it is definitely doable.

 

Hope this helps,

Ludwig

Agence Mi4 - Data DrivenCTO @ Mi4
Hubspot Platinum Partner and Integration Expert

Passionate human, very curious about everything data and automation.

Any problem with Hubspot you need help solving ?

Let me know !

0 Me gusta
Jaycee_Lewis
Administrador de la comunidad
Administrador de la comunidad

Anchor to search result

resolver

Hi, @dimitreliasb 👋 Do you have any insight or experience here @LMeert @miljkovicmisa @stefen?

 

Thank you very much! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Me gusta
stefen
Solución
Asesor destacado | Partner
Asesor destacado | Partner

Anchor to search result

resolver

like @LMeert said, it will take a bit of javascript work but it is possible. I'd probably use a function that checks for search term query parameter that would then scroll to the first instance of that term in the main content of the page. 

Stefen Phelps, Community Champion, Kelp Web Developer