CMS Development

dimitreliasb
Contributeur

Anchor to search result

Résolue

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 Votes
2 Solutions acceptées
LMeert
Solution
Guide | Partenaire solutions Platinum
Guide | Partenaire solutions Platinum

Anchor to search result

Résolue

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 !

Voir la solution dans l'envoi d'origine

0 Votes
stefen
Solution
Conseiller clé | Partenaire solutions
Conseiller clé | Partenaire solutions

Anchor to search result

Résolue

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

Voir la solution dans l'envoi d'origine

3 Réponses
LMeert
Solution
Guide | Partenaire solutions Platinum
Guide | Partenaire solutions Platinum

Anchor to search result

Résolue

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 Votes
Jaycee_Lewis
Gestionnaire de communauté
Gestionnaire de communauté

Anchor to search result

Résolue

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 Votes
stefen
Solution
Conseiller clé | Partenaire solutions
Conseiller clé | Partenaire solutions

Anchor to search result

Résolue

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