HUGO

Paywall with Hugo

Is there any way to create a paywall with Hugo? I know Netlify recently published an article about doing something similar to a paywall, but I’m not sure if there’s something easier around.

No, it is not possible with just Hugo.

You would need either a third party service (like Netlify) or configure the paywall yourself either on the front-end or server-side.

@alexandros is right. I think in general (even outside of Hugo) that this is much harder than it should be, especially for smaller member sites. Some time ago I wrote this issue, which I thinks is more or less also valid today (and something that I really want to do):

2 Likes

Roles can most definitely be something Hugo would benefit from. Currently, the only way to achieve this is by either using Netlify (not bad, but expensive at $99 per month) or by doing a mixed installation in a hosting capable of serving dynamic pages.

I’m writing this to let everyone know Hugo might not be made of stone, but it rocks. I am trying to build a paywall, with a member’s area.

This is what I’m going to be doing:

  • Static site with Hugo
  • PHP server to authenticate users
  • User goes to the static HUGO site.
  • User clicks the sign-up button.
  • User username and password travels through the cyberweb to the PHP site via AJAX, thus, registering an account on the PHP site.
  • Then, the user gets taken to the HUGO static site again.
  • The user enters his username and password.
  • Ajax to the PHP site.
  • Returns a cookie.
  • User stays logged in for the session.

Pages that need to be protected make an Ajax call before loading the content.

The only issue I see with this is, well, the content can be read via the source code.

This is beyond Hugo scope, but then again, I’m trying to build something here! Maybe I can come up with a solution that can help others.

There are other ways to create a paywall for a JAMStack site.

Have a look at this step-by-step that involves authentication via AWS.