Blog, Website & Page Publishing

RayOfSunshine
Participante

Trying to Filter Webpage Search Results by Subdirectory

resolver

I'm working on a website experience with two diverse experiences. www.example.com/Option1 and www.example.com/Option2. Additionally, I have blogs that are specific to the experiences at example.com/blog/Option1/BlogName and example.com/blog/Option2. At some point, the start point for the user journey will be a "choose your own adventure" page that is example.com/choose and has a CTA attached to the home page of each option.

Currently, Hubspot visual editor allows my top nav menu search bar to filter between types of content (website pages, landing pages, etc.), but I'm wondering what the best approach to filtering these blogs by experience would be. Considerations to include are SEO impact and user experience.

Is there a way to accomplish this without using a custom search bar and JavaScript to do the content slug filtering?

0 Avaliação positiva
1 Solução aceita
evaldas
Solução
Orientador(a) | Parceiro Platinum
Orientador(a) | Parceiro Platinum

Trying to Filter Webpage Search Results by Subdirectory

resolver

Hi @RayOfSunshine 

 

This probably depends on what you consider a "custom search bar" to be. If you're asking whether this can be done with a setting within HubSpot or the default modules, then no. However, this could likely be done by cloning and modifying the default search input module with some code and creating designated search result pages.

 

In the cloned version, you would need to add a hidden input field for pathPrefix and in the value attribute, you would add your subdirectory. This would be placed inside the <form> element (with a customized action attribute):

 

 

<form action="/Option1/search">
...
<input type="hidden" name="pathPrefix" value="Option1">
....
</form>

 

 

Then you would need to set up a page for your search results, which would be a regular website page (instead of a system page) but it would contain a search results module. Note that the URL of the search results page would need to follow what you have in the action attribute of the form element (i.e. www.example.com/Option1/search ).

 

Obviously you would need to make sure that the cloned search input is present in the header/footer (or wherever it will be placed) instead of the default search input module. 

 

In your case, you would need to do this twice (create a customized version for each of the options you mentioned).

 

No javascript needed 🙂

 

Hope this helps!


✔️ Did this post help answer your query? Help the community by marking it as a solution.

Exibir solução no post original

2 Respostas 2
evaldas
Solução
Orientador(a) | Parceiro Platinum
Orientador(a) | Parceiro Platinum

Trying to Filter Webpage Search Results by Subdirectory

resolver

Hi @RayOfSunshine 

 

This probably depends on what you consider a "custom search bar" to be. If you're asking whether this can be done with a setting within HubSpot or the default modules, then no. However, this could likely be done by cloning and modifying the default search input module with some code and creating designated search result pages.

 

In the cloned version, you would need to add a hidden input field for pathPrefix and in the value attribute, you would add your subdirectory. This would be placed inside the <form> element (with a customized action attribute):

 

 

<form action="/Option1/search">
...
<input type="hidden" name="pathPrefix" value="Option1">
....
</form>

 

 

Then you would need to set up a page for your search results, which would be a regular website page (instead of a system page) but it would contain a search results module. Note that the URL of the search results page would need to follow what you have in the action attribute of the form element (i.e. www.example.com/Option1/search ).

 

Obviously you would need to make sure that the cloned search input is present in the header/footer (or wherever it will be placed) instead of the default search input module. 

 

In your case, you would need to do this twice (create a customized version for each of the options you mentioned).

 

No javascript needed 🙂

 

Hope this helps!


✔️ Did this post help answer your query? Help the community by marking it as a solution.

RayOfSunshine
Participante

Trying to Filter Webpage Search Results by Subdirectory

resolver

Thank you for the response. That helps a bunch. A "custom search bar" to me is anything that requires enough customization that if it broke, it would take a front-end dev or someone who's moderately familiar with html or javascript to debug and repair. I'll keep your response in mind and if I end up using it, I'll be sure to mark it as the solution so you get the credit.