How can I create a password protected page without a Shopify app?

Hello everyone!

I had a hard time figuring this out so thought I’d post about it to help others.

I needed to create a password protected page for my client, and couldn’t find a solution beyond a paid Shopify app at first.

But, here is what you can do:

Create the page you want to be password protected. Make sure it’s name is unique, and use a word you don’t use in any other page.

Copy and paste this code into the theme.liquid file, a few lines after the first two lines.

{% if template contains “wholesale” %}

{% unless customer %}
{% assign send_to_login = true %}
{% endunless %}
{% endif %}

{% if send_to_login and request.path != “/challenge” %}

{% else %}

{% endif %}

Where it says: “wholesale”, change that to a word that is your unique word in your page name.

The only caveat here is that I couldn’t edit the page once it was password protected, so edit it first then add this last.

Enjoy!!

Renée