Restrict a page to only logged in users - (2.0) Dawn theme

Topic summary

A user wants to restrict a specific page to logged-in users only in Shopify’s Dawn 2.0 theme without using an app. They attempted several approaches:

Initial attempts (all unsuccessful):

  • Adding Liquid code to a Custom Liquid section on the page (doesn’t hide entire page)
  • Adding code to the page’s Content section under Sales Channels (doesn’t work)
  • Editing page.wholesale.json directly (causes errors, won’t save)

Solution provided:

  • The code belongs in the Liquid template file (main-page.liquid), not the JSON template
  • For Dawn themes, page.json references main-page.liquid for content control
  • To restrict only specific pages: duplicate main-page.liquid, rename it (e.g., main-page-wholesale.liquid or main-page-customer.liquid), add the customer login check code, then reference this new template in the corresponding JSON file

Additional context:

  • One user asked about restricting the entire site except the homepage to logged-in users
  • Suggested approach: wrap the desired content in theme.liquid with {% if customer %} conditional logic
  • A video guide was referenced for limiting access to products/pages
Summarized with AI on November 12. AI used: claude-sonnet-4-5-20250929.

I want to make a certain page hidden unless the user is logged in without an app. I’ve seen the code that has been posted (below), but I am not sure where to put the code in the 2.0 theme. Here is what I’ve tried:

  • Adding it to the “Custom Liquid” section that I can add to the page - but it is not quiteright since I want to hide the entire page.
  • Adding it to the page code itself page.wholesale.json, but it gives me errors and won’t save.
  • Adding it to the Content section on the Page itself (under Sales Channels) but that doesn’t work.

Here is what I’m working with:

{% if customer %}
THE ENTIRE PAGE CONTENTS
{% else %}

This page is restricted to wholesale customers.

{% endif %}

Hi @SKRASTS it’s not in page.wholesale.json as that is a JSON template file not a liquid file.

The json references the liquid templates it does use allowing for the new dynamic sections system in OS2.0 .

For dawn based themes the liquid template would be main-page.liquid

https://github.com/Shopify/dawn/blob/main/templates/page.json#L4

For third party themes you may need to figure out what templates page.wholesale.json references.

If you still can’t find it and need direct support you can contact me at paull.newton+shopifyforums@gmail.com so I have context please provide store url, theme name, and problem description or post-url.

  • Adding it to the Content section on the Page itself (under Sales Channels) but that doesn’t work.

Assuming you mean the online-sales channel, keep in mind other channels may expose products or content if they have access to it by being published as they do not use a stores theme logic for content control.

Okay, my page uses the main-page.liquid.

If I add it there though, all the pages that use that main-page.liquid will need to be logged in, right?

Should I duplicate that main-page and call it customer-page.liquid and reference that liquid file with the .json file?

Should I duplicate that main-page and call it customer-page.liquid and reference that liquid file with the .json file?

Basically yes; or name it main-page-wholesale.liquid , or main-page-customer.liquid etc to maintain consistency.

Hi Paul

Just stumbled across this and wondered if you could help please. I’m using Dawn and want to limit everyone to the home page unless they are logged in. I’ve worked out how prevent customers from creating their own accounts, but not sure how to stop visitors from moving around the website. As this is a single product website, I’m hoping to do this with coding rather than app.

Thanks for any help.

1 Like

@BonzaDogTreats just use the code wrapping it around for the entire part of the site content you want to now show in theme.liquid

Hi @SKRASTS , looking to limit access to certain products or pages on your Shopify store? This video guide has the answers: