How to hide all pages from search results

Solved
Highlighted
Explorer
96 0 4

@tim 

Not my customers in general, no, but a super cool savvy particular customer...possibly :/, and I definitely don't want customers having access to those internal pages (of course those pages don't contain sensitive info...but prefer customers not to be able to see them)...

 

I'm not sure how to go about your suggestion, any ideas?

 

Another workaround I'm wondering is: on my Search results, I show the Image, Title, and Body/Description of products, pages, etc. Can I hide just the title and body/description of the pages *only* so that if said super cool savvy particular customer searches the page, it comes up blank?

0 Likes
Highlighted
Explorer
96 0 4

@tesstesting wrote:

@tim 

Not my customers in general, no, but a super cool savvy particular customer...possibly :/, and I definitely don't want customers having access to those internal pages (of course those pages don't contain sensitive info...but prefer customers not to be able to see them)...

 

I'm not sure how to go about your suggestion, any ideas?

 

Another workaround I'm wondering is: on my Search results, I show the Image, Title, and Body/Description of products, pages, etc. Can I hide just the title and body/description of the pages *only* so that if said super cool savvy particular customer searches the page, it comes up blank?



Just an update for anyone that may be interested...here's how I totally eliminated pages from the search page if users typed the page name into the search box or used an URL.

 

I used Tim's code to eliminate all pages from search results. This made only products and articles come up with the title and description of each item. I only need products in search results to come up. Only minor problem was, if users used URL to search (highly unlikely but best to cover all bases), they could still see the page title and page content if they typed this: mywebsite.com/search?type=pages&q="a" into the url.

 

To eliminate this issue I used this code on my search.liquid:

{% for item in search.results %}
      <li class="list-view-item">
          {% if item.object_type == 'product' %}
            {% include 'product-card-list', product: item %}
          {% else %}
        
        <span class="visually-hidden">

I added span class visually hidden to everything else and closed with:

</span>

Furthermore, if by some chance customers got to the page...I wanted the page to redirect to the contact page.  So I followed Tim's solution code in this thread.

Here's his suggestion from that thread: 

@tim 

You should create an alternate template for Pages and assign it to this page. Since we do not want visitors to see the content, this template can be similar to:

  {% layout none %}
  <script>    window.location.replace("/pages/contact-us");
  </script>

This will redirect to the Contact Us page instead.


 

PS. Here's a thread about how to hide pages with certain tags if thats what you're looking for: "How to omit products or pages tagged with 'wholesale" in search results"

0 Likes