CMS Development

Parul
Participante

Search within blog posts

resolver

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

 

https://blog.hubspot.com/service

 

It should search only within blogs

0 Me gusta
2 Soluciones aceptadas
Stephanie-OG
Solución
Asesor destacado

Search within blog posts

resolver

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!

Ver la solución en mensaje original publicado

0 Me gusta
Stephanie-OG
Solución
Asesor destacado

Search within blog posts

resolver

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!

Ver la solución en mensaje original publicado

6 Respuestas 6
SSafi
Miembro

Search within blog posts

resolver

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 Me gusta
Wlocus33
Miembro

Search within blog posts

resolver

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 Me gusta
Stephanie-OG
Solución
Asesor destacado

Search within blog posts

resolver

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!

0 Me gusta
Parul
Participante

Search within blog posts

resolver

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 Me gusta
Stephanie-OG
Solución
Asesor destacado

Search within blog posts

resolver

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!

Parul
Participante

Search within blog posts

resolver

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 Me gusta