Search within blog posts

SOLVE
Parul
Participant

I want to create sub-navigation search as it is in:

 

https://blog.hubspot.com/service

 

It should search only within blogs

0 Upvotes
2 Accepted solutions

Accepted Solutions
Stephanie-OG
Solution
Key Advisor

Hi there!

 

If you're using HubSpot's default "Site Search Input" module you should see options to specify the type of content that should be included in the search results: 

 

Site Search - Type of Content.jpg

 

You can also clone and customise the module further if you wanted it to only search a particular blog (if you have multiple). I wrote a short article on how to do this here: Add parameters to your HubSpot site search input module

 

I hope that helps!

 


Stephanie O'Gay Garcia

HubSpot CMS Design & Development

Website | Contact

 

If this helped, please mark it as the solution to your question, thanks!

View solution in original post

0 Upvotes
Stephanie-OG
Solution
Key Advisor

You should be able to copy the code from the module and use it anywhere, so something like this should work:

 

 

<form action="/{{ site_settings.content_search_results_page_path }}">
  <label for="term">Field Label</label>
  <input type="text" class="hs-search-field__input" name="term" autocomplete="off" aria-label="Field Label | Search" placeholder="Placeholder text">
</form>

 

And you can also use the additional customisations, such as only searching on the blog:

 

<form action="/{{ site_settings.content_search_results_page_path }}">
  <label for="term">Field Label</label>
  <input type="text" class="hs-search-field__input" name="term" autocomplete="off" aria-label="Field Label | Search" placeholder="Placeholder text">
  <input type="hidden" name="type" value="BLOG_POST">
  <input type="hidden" name="type" value="LISTING_PAGE">
</form>

 

I don't believe there's a HuBL module or anything else you can use instead. 

 

 


Stephanie O'Gay Garcia

HubSpot CMS Design & Development

Website | Contact

 

If this helped, please mark it as the solution to your question, thanks!

View solution in original post

6 Replies 6
Stephanie-OG
Solution
Key Advisor

Hi there!

 

If you're using HubSpot's default "Site Search Input" module you should see options to specify the type of content that should be included in the search results: 

 

Site Search - Type of Content.jpg

 

You can also clone and customise the module further if you wanted it to only search a particular blog (if you have multiple). I wrote a short article on how to do this here: Add parameters to your HubSpot site search input module

 

I hope that helps!

 


Stephanie O'Gay Garcia

HubSpot CMS Design & Development

Website | Contact

 

If this helped, please mark it as the solution to your question, thanks!

View solution in original post

0 Upvotes
Parul
Participant

Hi there!

Thanks for your solution with default "Site Search Input" module.
But I don't want to use it and want to create this search completely by custom code.
So is there a way, I can search within hubspot blogs using custom code?

Thanks,
Parul

0 Upvotes
Stephanie-OG
Solution
Key Advisor

You should be able to copy the code from the module and use it anywhere, so something like this should work:

 

 

<form action="/{{ site_settings.content_search_results_page_path }}">
  <label for="term">Field Label</label>
  <input type="text" class="hs-search-field__input" name="term" autocomplete="off" aria-label="Field Label | Search" placeholder="Placeholder text">
</form>

 

And you can also use the additional customisations, such as only searching on the blog:

 

<form action="/{{ site_settings.content_search_results_page_path }}">
  <label for="term">Field Label</label>
  <input type="text" class="hs-search-field__input" name="term" autocomplete="off" aria-label="Field Label | Search" placeholder="Placeholder text">
  <input type="hidden" name="type" value="BLOG_POST">
  <input type="hidden" name="type" value="LISTING_PAGE">
</form>

 

I don't believe there's a HuBL module or anything else you can use instead. 

 

 


Stephanie O'Gay Garcia

HubSpot CMS Design & Development

Website | Contact

 

If this helped, please mark it as the solution to your question, thanks!

View solution in original post

Parul
Participant

Thanks for reaching out 🙂

We can do it this way and can also achieve it by implementing custom search using jQuery.

We can use following code to call blogs in custom module and then can implement search in it.

{% set all_posts = blog_recent_posts('default', 200) %}

{% for all_post in all_posts %}
<div class="post-title"><a href="{{all_post.absolute_url}}">{{ all_post.name }}</a></div>
{% endfor %}



Thanks

0 Upvotes
Wlocus33
Member

Once I did the export it had the primary column as a gaggle of complicated URLs (that appears to be the string of numbers you noted), but then the column next to it has the everyday name of the weblog web page itself as you can read here. I did notice that I needed to expand the columns because it was very bunched together at the start. Column B turned into the only that had the real titles of the weblog pages.

0 Upvotes
SSafi
Member

Hi everyone, I know  wordpress and i have built a site  in it, but i have multiple pages on my site and i also need a sub navigation search, does the above codes will help me if i export them ?

0 Upvotes