I understand that .htaccess is not supported by GitHub Pages. I wonder if there is an alternative for password-protecting particular directories for websites hosted by GitHub Pages.


Unfortunately, GitHub pages only supports static pages. There is no way to make it execute server-side code and thus it's impossible to protect your pages with any kind of authentication scheme. If you expand further on why you need to password-protect your pages, maybe I can help you find a workaround.

  • Here's a scenario. You have a simple set of static pages, just some html/css/js, and you want to share it with only a few collaborators during development testing, using Github Pages to test until you're ready for production to put on a public host. Years ago I would DDNS a local machine on a local network, but I was wondering if there was a free public protected hosting service just basically for development testing, that wasn't as extensive in setting up as, say, Azure or Amazon, for simple static pages, although my interests today have gone into .NET Core, PHP, and NodeJS on the backend. – John Ernest Jul 16 '19 at 2:23

Closest I've been able to find is https://github.com/matteobrusa/Password-protection-for-static-pages

Essentially, we'd want to have this so that we can restrict some information.

I think it should be possible to do something a bit more elegant with Javascript, but I'm not a JS guy.

This doesn't actually do anything beyond obfuscate the information, but that's good enough for a lot of data.

I imagine you could use that password to decrypt data,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.