How can I hide specific pages from store search results?

Im trying to hide some specific pages from store search with the followoig code

I created a metafield for the page. It wont let me create the seo.hidden metafield (is that just for products?) so I created this one that can just be set to 1 and we can check it for a value.

But the page is still appearing in store search. I am using the flex theme.

I placed this code in the section.

{% if template contains ‘page’ %}
{% if page.metafields.custom.hide_page == 1 %}

{% else %}

{% endif %}
{% endif %}