Recommended Section Authentification

Hi,

I need to make a couple sections of my site accessible to specific users. What are the recommended ways to achieve this?

Thanks,
Winefred

If you are hosting on apache you can use htaccess/htpasswd authentication probably. If I were trying it I would try to put the files in your section folder.

Thanks Rick for your reply. I should have given more context for my question. My current site runs apache and uses a small server; however, if possible I would like to loose the server all together and host the website in an AWS S3 bucket. Given that goal, is anyone aware of an alternative to htaccess?

I have not tried it but, apparently you can do that with AWS Lambda:

https://hackernoon.com/serverless-password-protecting-a-static-website-in-an-aws-s3-bucket-bfaaa01b8666

Thanks again. That looks like it is worth a try!

1 Like

How can I do this? If I name the file “.htaccess” it is not copied to public.

Did you put it in your static/ folder?

No, I wondered if it is possible to put it in content right inside the section folder.

Yep, it definitely needs to be in /static but, re-reading the apache spec for it, apparently you put an .htaccess in the folder you need to secure. So, I have not tried it, but if I were going to, I would mimic the section folders inside /static, put .htaccess where it’s needed, and then see if Hugo will merge it smartly. Or, does the section stuff get clobbered when you try this. You need to experiment.

For the records: It works this way. Just mimic your content section folder path in static and put the .htaccess there.

If you have this:
content/private/

put the file there:
static/private/.htaccess

1 Like