Update Nov 2023
In this guide we’ll show you how to create customizable gated content (a paywall) so that some content is only accessible to certain customers, using a custom blog and article template. Just like the one you can see here: https://www.pogodan.com/blogs/members-only
We'll assume for the purposes of this guide that you're already using a subscription app or have some other group of customers that you want to offer special access to, and all those customers are tagged with a specific tag. If you're using a subscription app, they will likely already be tagged.
Our members are tagged "member".
Create two new templates
In the theme we're using, both the blog and the article only have a reference to a section template in them. In your theme there may be more code in there, in which case you'll need to modify the code accordingly.
In the code editor, create two new files, blog.protected-content and article.protected-content and replace them with this code. Note that the sections template--blog
and template--article
are sections used in the theme, so if yours are named differently, adjust the section names.
If you're using a different tag than "member" or you're using a metafield or something else to determine if the customer has access, you will need to modify line 1 on both of these templates.
blog.protected-content.liquid
{% if customer.tags contains 'member' %} {% section 'template--blog' %} {% else %} {% section 'template--protected-content' %} {% endif %}
article.protected-content.liquid
{% if customer.tags contains 'member' %} {% section 'template--article' %} {% else %} {% section 'template--protected-content' %} {% endif %}
Add the protected content section
Create a new section called template--protected-content.liquid
.
Paste in the contents of this file.
Create your content
Add a new blog in Shopify. Make sure to select the "protected-content" template. Then add an article, again selecting the "protected-content" template.
Need Help?
This article and code snippets are designed for you to be able to do this yourself, but if you don't feel comfortable or want us to install the code for you, you can purchase our installation service.