CMS Development

dimitreliasb
Mitwirkender/Mitwirkende

Anchor to search result

lösung

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 Upvotes
2 Akzeptierte Lösungen
LMeert
Lösung
Ratgeber/-in | Platinum Partner
Ratgeber/-in | Platinum Partner

Anchor to search result

lösung

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 !

Lösung in ursprünglichem Beitrag anzeigen

0 Upvotes
stefen
Lösung
Autorität | Partner
Autorität | Partner

Anchor to search result

lösung

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

Lösung in ursprünglichem Beitrag anzeigen

3 Antworten
LMeert
Lösung
Ratgeber/-in | Platinum Partner
Ratgeber/-in | Platinum Partner

Anchor to search result

lösung

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 Upvotes
Jaycee_Lewis
Community-Manager/-in
Community-Manager/-in

Anchor to search result

lösung

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 Upvotes
stefen
Lösung
Autorität | Partner
Autorität | Partner

Anchor to search result

lösung

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