If you have a Shopify website with standard or predictive site search , it bypasses the exclusion methods above. However, there is a simple way to exclude pages from local site search results using metadata.
Page Cloaking with Metaobject Shopify allows you to create a variety of web page types, called page, product, collection, and article (blog posts). When I say that you can hide a page, it applies to any of the types.
Each web page includes underlying HTML formatting code. There are also scripts affecting the appearance and functionality of a page. Metadata are hidden parameters beyond the underlying HTML.
In the past, a third-party tool was required to edit metadata. Now, it’s possible within the standard Shopify admin interface. The nice thing about this is that it requires no programming code so it survives theme updates.
There are two ways to gain access to the control panel. Within the Admin, click Content: Metaobjects: Add definition . The other method is to click Settings: Custom data .
From here, you select the page type (Products, Collections, Pages, Blog posts). For this example, we will hide a blog post. In the next window create a definition entitled Hide page from search
in the Name field. (It can be anything but this is explicit.) Regardless of the page type, the next field called Namespace and key must be exact: see.hidden.
The Description provides visible instruction when you get ready to hide a page: 1 hides article; clear 1 to show
. Then Select type is Single line text
, one value. Beneath Validations , click Limit to preset choices
. Type the numeral 1
before clicking the Add item button. Save the metaobject and close the editing window.
Navigate to the area for testing. Online Store: Blog posts . Here, you can select an existing article or create a new one with the title, “Test Vanishing Page.” For a new page, you must save it to access the feature. Scroll down to the area entitled Metafields and click Show all . Next to the field called Hide page from search, there is a menu with a single selection of 1
. You will also see the description that instructs you how to disable the feature.
Visit the front end of the store to type words from your blog post title into the site search field. It will not be visible within the results. Return the Admin area to clear the 1
and save. Refresh your public site and try again. You should see it within the search results.
What have we done? We have created a foolproof way of hiding a page from your local site search without any programming. The metaobject produces the interface for adding a hidden metadata field called see.hidden with a value of 1
. By using a menu for this value, we eliminate the possibility of typing invalid characters.
See: Add Shopify Text Metafields
ClinicalPosters moderates comments and requires user login to reply. Are you interested in more tips like this? Let me know what you think in the comments section below.