Utilizing native the site search functionality within the HubSpot CMS, Content Search. The HubSpot CMS has built-in site search functionality to allow your visitors to easily find the content they are looking for.
type=BLOG_POST
to only return blog posts. Or, if you wanted to build search into the Spanish version of your website, you could query language=es
to only return Spanish pages.
The API returns JSON that can be parsed with JavaScript to display the results on your website. All content types will return the page domain, title, url and language. The description returned is a sample of text from the content which best matches the search term. A <span class="hs-search-highlight hs-highlight-html">
element will wrap perfectly matching text, allowing you to highlight matching text with CSS.
Depending on the type of content searched, the results return slightly different information, so you can display results for unique content types differently. For example, blog posts will return information on which tags the post has, who the author is, and when it was published.
search_input
and search_results
.
{% module "search_input" path="@hubspot/search_input" %}
.
hs fetch @hubspot/search_input.module
or hs fetch @hubspot/search_results.module
.
hs-search-keyword
class.
robots.txt
you can tell HubSpot to crawl everything, while blocking other bots.
robots.txt
.Also remember to review your robots.txt
prior to launch to ensure everything indexes how you want it to.robots.txt
file or via meta
tags, they will not be indexed for site search.
In your robots.txt
add a disallow
.
NOINDEX, NOFOLLOW
meta tag in the <head>
at the page or template level.
robots.txt
and the meta tag. Doing so can make it confusing later if you decide to allow indexing of a page.hs-search-hidden
to your HTML for those regions to have search ignore the content inside.