CMS Development

dimitreliasb
Colaborador(a)

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 Avaliação positiva
2 Solução aceitas
LMeert
Solução
Orientador(a) | Parceiro Platinum
Orientador(a) | Parceiro 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 !

Exibir solução no post original

0 Avaliação positiva
stefen
Solução
Conselheiro(a) de destaque | Parceiro
Conselheiro(a) de destaque | Parceiro

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

Exibir solução no post original

3 Respostas 3
LMeert
Solução
Orientador(a) | Parceiro Platinum
Orientador(a) | Parceiro 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 Avaliação positiva
Jaycee_Lewis
Gerente da Comunidade
Gerente da Comunidade

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 Avaliação positiva
stefen
Solução
Conselheiro(a) de destaque | Parceiro
Conselheiro(a) de destaque | Parceiro

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