juin 13, 2022 3:20 PM
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?
Résolu ! Accéder à la solution.
juin 14, 2022 5:11 AM
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
![]() | CTO @ 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 ! |
juin 14, 2022 7:56 AM
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.
juin 14, 2022 5:11 AM
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
![]() | CTO @ 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 ! |
juin 13, 2022 3:38 PM
Hi, @dimitreliasb 👋 Do you have any insight or experience here @LMeert @miljkovicmisa @stefen?
Thank you very much! — Jaycee
juin 14, 2022 7:56 AM
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.