Is there a way to even do this with a static site? Obviously needs some kind of active interaction somewhere. I think I can use a hosting service like firebase to handle authentication…and a service like snipcart could handle payments? There are a lot of ecommerce solutions out there, and I thought this would be a simpler problem, but I am having trouble finding examples.
If you search around the forums there are ways to kinda sorta password protect things, but what you are asking is not “static”. At some point you need a dynamic interaction model, and while Hugo can provide the static content pages, it isn’t made for any other part of such a site.
Netlify and Firebase, these services have their own authentication backend, but that ain’t Hugo, so there are better places to ask your questions.
Completely untested but, I suppose you could kind of make it work using
.htpasswd targeting a specific sub-folder of content, and you can even script those things. It’s not really flexible, but if you had just a folder or two of content to be protected, it might work. This is Apache authentication and has nothing to do with Hugo, except, you might use your Hugo deploy process to get the updated
.htpasswd file up on to the server.
I would like to revitalize this thread because we are looking to do the same thing for implementing a new SaaS on Hugo. In addition, we would like to restrict content on the site based on their membership tier. For example, free and paid users would have access to the same web page / url but paid members will see more content than free members.
Wordpress has plugins to monetize CMS sites including logins, paid subscriptions and page content restrictions. Netlify’s Identity product appears to offer some of these features but not to the extent of paid tiered membership and content restriction. Has anyone else seen these kind of monetization implementations on Hugo or another static site generator?
That way some of the pages were readable only by members, while others could read only the public pages.
From what I understand it’s possible to combine Netlify Identity with an external service. For membership management you could use Gumroad, SendOwl, and the likes. They both have APIs, so it might be possible to connect a Netlify Function with the membership API to see if a user logged in with Netlify Identity is registered. Perhaps that would work, depending on how much time and effort you want to throw at it?