Skip to main content
All articles
  • Password Protection
  • Client Previews
  • Static Sites
  • Web Hosting

How to Password Protect a Website or Page: 5 Methods (2026)

Updated Published 15 min read

On this page 11 sections

To password protect a website, use your host's built-in password or email-whitelist feature: the host checks every visitor before it sends a single page, and setup takes minutes with no server work. On WordPress, Squarespace or Wix, that's the page or site password setting in the editor. Running your own Apache or Nginx server? Use basic auth. Want people to sign in with their own Google or Microsoft account? Put Cloudflare Access in front. For one static page with no server at all, StatiCrypt encrypts the page itself. And skip JavaScript snippets that check a password in code, because the password sits right there in the page source.

The usual reasons to password protect a website's pages: a client preview before launch, a staging site for stakeholders, a wedding site that shouldn't show up in Google, internal docs. Same need every time - something has to check who's asking before the page is readable. That check is what makes a password-protected website.

On Vercel, Netlify, Framer, Webflow or GitHub Pages? Jump to the platform walkthroughs.

No. Two quick definitions, because this is the step that trips people up most:

  • Obscured means the URL is hard to guess: a Google Drive share link, an unlisted YouTube video, a Notion page with a long hash in the URL.
  • Protected means the server checks who you are before it sends any bytes.

Obscured URLs leak. People paste links into Slack, forward emails and sync bookmarks across devices. One screenshot in a group chat and the "private" link is out.

Shared password or email whitelist: which should you use?

Use an email whitelist for people who'll come back (client rounds, staging, internal docs), and a shared password for a one-off group like wedding guests. Pick the model first, then the method.

Shared password. One string everyone types. Simple, instant, no accounts. Two weak spots: it forwards, and locking one person out means changing the password and resending it to everyone else. Fine for a wedding site with 80 guests; tedious by round two of a client preview.

Email whitelist. You list the email addresses allowed in, and only those people get through. How a visitor proves they own an address depends on the service (Cloudflare Access, for example, emails a one-time PIN, and only to addresses its policy allows). On Hostsmith, a visitor on the list signs in with Hostsmith using the Google account at that address, and the first visit sets up their account; a password visitor needs no account at all. Removing one person means removing one email, and a fourth reviewer mid-project doesn't disturb the first three. More on that workflow in the client preview guide.

How to password protect a website: 5 methods

All five work whether you're gating a whole website or a single web page. Methods 1 to 4 run from least to most hassle; method 5 is for a single static page.

1. Your host's built-in password protection (easiest)

The host checks the password or email before serving anything, with no server-side code to add. What the main hosts and builders offer, checked November 24, 2026 (each name links to its source):

PlatformWhere the setting isPlan needed
HostsmithPrivate Sites: a shared password or an email whitelist, whole siteStarter and up: $5/mo billed yearly, $9 billed monthly
NetlifyProject visibility, one shared passwordPro, $20/mo for the whole team; not Free or Personal
VercelDeployment Protection > Password ProtectionPro, plus $20/mo per protected project; not Hobby
SquarespaceSite Availability > Password Protected, or a page's settings > PasswordAny site, trial sites included; a site-wide password blocks checkout
WixSettings > Site Password, or a page's Settings > Access > Password holdersNo plan named in Wix's help; site-wide is "not currently available to all users"
WebflowSite settings > General > Website password, or a page's or folder's settingsA paid Site plan; site-wide also on Growth, Agency or Enterprise Workspaces
HubSpotPage editor > Settings > Password requiredContent Hub (or legacy CMS Hub) Professional or Enterprise

Whatever the platform, test the gate in a private browser window, as Squarespace's help suggests: a session from your own visit can walk straight past it.

No host yet? The host an HTML file online walkthrough covers the basics, and there's a separate guide on how to publish a Claude artifact privately.

2. WordPress page passwords

Every WordPress post and page has a Password protected option. Per WordPress.com's support guide: open the post or page, click the settings icon at the top right of the editor, click the link next to Status, choose Password protected, type the password, then Save or Publish.

Three limits before you rely on it:

  • It protects the post content only. WordPress.com warns that images and files added to a protected post can still be indexed by search engines and opened directly without the password, so a client mockup uploaded as an image isn't gated.
  • The password is capped at 20 characters, per the WordPress.org docs.
  • It works page by page, with no switch for the whole site.

3. .htaccess + .htpasswd on Apache

Still the right answer if you control an Apache server. Two files, and Apache asks for a username and password before serving anything in that directory.

The .htaccess file:

Text
AuthType Basic
AuthName "Restricted Area"
AuthUserFile /full/path/to/.htpasswd
Require valid-user

Generate the password file on your machine:

Text
htpasswd -c .htpasswd preview

That writes one line: the username preview, then the hashed password. The -c flag creates the file and wipes any existing one, so use it only for the first user. To add another, drop the flag: htpasswd .htpasswd reviewer2. Move .htpasswd to the path in AuthUserFile, outside the web root so nobody can download it, then reload Apache.

The gotcha you'll probably hit first: Apache only reads auth rules from .htaccess if the main config sets AllowOverride AuthConfig (or All) for that directory. If it doesn't, nothing errors - the password prompt just never appears. On shared hosting, where you often can't edit the main config, use the host's own password feature instead.

Nginx does the same with auth_basic "Restricted Area"; plus auth_basic_user_file pointing at a password file that the same htpasswd tool generates.

With a username per viewer, htpasswd -D .htpasswd reviewer2 removes one person, and Apache's Common Log Format records the username on each authenticated request. What basic auth won't give you is a styled login page, sign-in with Google or Microsoft, or emailed codes.

4. Cloudflare Access

The strongest option. Cloudflare Zero Trust's Free plan has a 50-user limit, and the Pay-as-you-go plan is $7 per user per month (checked November 24, 2026). Visitors sign in with an identity provider you connect, such as Google or Microsoft, or with a one-time PIN emailed to addresses your policy allows. You can revoke one person's session and read authentication logs in the dashboard.

The setup:

  1. Get the domain onto Cloudflare, as an active domain with a full or partial (CNAME) DNS setup.
  2. Go to Zero Trust > Access controls > Applications, select Create new application, choose Self-hosted and private, then Add public hostname and pick the hostname to gate (for example staging.example.com).
  3. Add an Allow policy. Applications deny everyone by default, so the policy lists the allowed emails, an email domain (@yourcompany.com) or an identity provider group.

First time through, budget an hour. Overkill for a wedding site.

5. Encrypt the page itself: StatiCrypt or PageCrypt

StatiCrypt and PageCrypt are open-source tools that encrypt your HTML file with a password before you upload it. The host serves scrambled content plus a password box, and the right password decrypts the page in the visitor's browser. The password itself isn't in the file.

With StatiCrypt, it's one command (Node.js required):

Text
npx staticrypt index.html

It asks for the password and writes the encrypted copy to encrypted/index.html, the file you upload. Per StatiCrypt's README (checked November 24, 2026), it uses AES-256 through the browser's Web Crypto API and stretches the password with 600,000 rounds of PBKDF2-SHA256, so every guess is slow. Render's PageCrypt guide walks through the same job with PageCrypt.

Real protection for the page's content, with three limits:

  • It's only as strong as the passphrase. Anyone can download the file and guess offline. StatiCrypt's README recommends 16 or more characters.
  • One shared password, no logs. You can't remove one person or see who opened the page.
  • Only the HTML is encrypted. A linked image is a separate file anyone with its URL can open. Render's guide says to inline styles, scripts and images if they need protecting too.

Skip this one: JavaScript password snippets

Some tutorials prompt for a password in JavaScript, compare it to a string in the code, and redirect to a secret URL on a match. That protects nothing. The password, the comparison and the "secret" URL all ship in the page source, readable in DevTools in seconds, and the "protected" page is a normal public file that search engines can fetch.

Which method should you pick? Cost, security and setup compared

The host's built-in gate covers most sites. Each method links to its source where one exists.

MethodCost (Nov 24, 2026)Security and setup
Hostsmith Private SitesStarter plan and up: $5/mo billed yearly, $9 billed monthlyChecked by the host; shared password or email whitelist. Setup: low, no server admin
Netlify site passwordPro plan, $20/mo; not on Free or PersonalChecked by the host; shared password. Setup: low
Vercel Password Protection$20/mo per protected project on Pro; not on HobbyChecked by the host; shared password. Setup: low
Squarespace site or page passwordPart of any Squarespace site, trial sites includedChecked by the host; shared password; a site-wide password blocks checkout. Setup: low
WordPress post or page password (.org, .com)No extra cost on a WordPress siteContent only; attached images and files stay reachable; 20-character cap. Setup: low, per page
.htaccess + .htpasswd (or Nginx auth_basic)No extra cost on a server you runStrong over HTTPS; shared or per-user passwords; usernames in the access log. Setup: medium, needs shell access
Cloudflare AccessFree plan up to 50 users; Pay-as-you-go $7/user/moVery strong; per-person login, logs and revocation. Setup: high, domain must be on Cloudflare
StatiCrypt or PageCrypt (client-side encryption)$0Strong only with a long passphrase; one shared password; no revocation or logs; linked files not encrypted. Setup: low to medium, one command per change
JavaScript password snippet$0None; the password is in the page source. Setup: low

How do you password protect a static site?

Put the gate on the host, so every file in the folder sits behind it: HTML, images and PDFs alike. With no host gate and one page to protect, StatiCrypt (method 5) is the fallback.

The host route on Hostsmith, for a folder of HTML files and images:

  1. Zip the folder and drop the ZIP on the box at hostsmith.net. It takes a single file or a ZIP, then asks you to sign in to publish. The drag-and-drop hosting walkthrough covers the basics.
  2. Be on Starter or higher. Starter holds one site with 50 MB of storage; Pro ($15 a month billed yearly) holds five sites with 500 MB.
  3. Protect the site with Private Sites and pick a mode: a shared password or an email whitelist.
  4. Grab the URL and send it. On the shared domain it looks like your-site.us.hostsmith.link or your-site.eu.hostsmith.link, since every plan, Free included, can host in the EU or the US. On Pro and up you can use your own domain instead, with no region prefix.

Hostsmith hosts the live site too, so the same account serves the public version at launch. A public site and a protected staging copy side by side means Pro, since Starter has one site.

Is the "site" really one PDF? See the PDF hosting guide, or create a link to a PDF if a plain link is enough. On Google Drive? A Doc can't take a password, so password protect a Google Doc covers what works instead, and the Google Drive website hosting alternatives cover moving the files.

Can you password protect a website without paying?

Yes, if your domain is on Cloudflare (Access on the Free plan, up to 50 users, the strongest no-cost option), or with StatiCrypt and PageCrypt, which are open source and work on any static host; use a long passphrase. If you already pay for your own Apache or Nginx server, or for a WordPress, Squarespace or Wix site, their built-in passwords add nothing to the bill.

Netlify, Vercel and GitHub Pages have no shared password at no cost. Vercel Authentication works on every plan but admits only signed-in Vercel users with access, and on Hobby only one external user per account, per Vercel's Vercel Authentication docs (checked November 24, 2026). A private project on Netlify's Free or Personal plan is visible only to the team owner. Neither works for a client or a wedding guest, and Vercel's one Hobby Shareable Link is a hard-to-guess URL again. Hostsmith Private Sites starts on Starter; the Free plan doesn't include it.

Password protecting a site on a specific platform

Already committed to a platform? Each one has a focused walkthrough:

Best practices: passphrases and HTTPS

Use a long passphrase

Length beats cleverness. Four random words like fig-orbit-moss-yak (18 characters) are far harder to brute-force than P@ssw0rd1, and easier to type. NIST's SP 800-63B (revision 4) agrees: passwords used on their own should be at least 15 characters, with no forced character-mix rules.

Platform caps get in the way. WordPress post passwords stop at 20 characters, per the WordPress.org docs. Squarespace page passwords stop at 30, per its Page passwords help article, and Wix site passwords at 15, with no special characters such as %, ! or @, per the Wix Help Center, all checked November 24, 2026. There, use the longest random string the box takes. For StatiCrypt or PageCrypt, go longer, because the file can be attacked offline.

Don't ship a password without HTTPS

Basic auth sends the password with every request, and Apache's docs say it travels unencrypted unless the connection uses TLS. On your own server, install a certificate (Let's Encrypt is the usual pick) and redirect http:// to https:// before you turn the password on.

When another option fits better

  • You're handling regulated data. HIPAA, SOC 2, PCI: a password on a static site doesn't meet those requirements on its own. That takes an application with audit trails.
  • You want to stop downloads or screenshots. A password decides who gets in. Once a viewer is in, they can save, screenshot or screen-record whatever they see.

Most client previews and pre-launch sites aren't any of those, and a password or whitelist is exactly right.

Does Google index a password-protected website?

Not if the gate answers with an error status. Basic auth sends Googlebot a 401, and Google says it doesn't index URLs that return a 4xx status and drops indexed URLs that start returning one. For a staging site, that's what you want.

StatiCrypt and PageCrypt pages work differently: the host serves the encrypted file with a normal 200 status, so search engines can index the password prompt, while the content stays unreadable without the passphrase. If that bothers you, give the page a noindex tag.

Skip robots.txt for this. Google says a URL blocked in robots.txt can still appear in results if other pages link to it, and a blocked crawler never sees a noindex tag either.

The real indexing risk is an obscured URL with no gate: one public link to it and it can land in search like any other page. At launch, remove the gate and Google crawls the site as usual.

FAQ

How do I password protect a website? Turn on your host's built-in password or email whitelist. On your own server, use basic auth; for one static page with no server, StatiCrypt.

How do I access a password-protected website? With the password or the invite the site's owner sent you. For a shared password, open the link and type it into the prompt. For an email whitelist, sign in with the invited address; on Hostsmith that's signing in with Hostsmith using the Google account at that address, while a Hostsmith password link needs no account. Without either, ask the owner: a check on the server has no side door.

How do I password protect a site I just deployed? Use the protection setting on the host it's deployed to: a site password on Netlify Pro, Password Protection on Vercel Pro, or Private Sites on Hostsmith Starter and up. If the host has no gate, put Cloudflare Access in front of its custom domain (except GitHub Pages on a public repo, where the files stay readable on GitHub), or move the site to a host that has one.

Can I password protect a web page instead of the whole site? Yes. WordPress, Squarespace and Wix set passwords on individual pages. StatiCrypt encrypts one HTML file so it opens only with the password, on any static host. On a host that protects whole sites, upload that one page as its own site and protect it.

How do I password protect a wedding website? Use your builder's password setting (Squarespace and Wix both have page passwords), or upload the site to a host with built-in protection and share one password with your guests. Don't send it with a "forward freely" note - at that point it's back to being an obscured link.

How do I password protect a website on Wix? In the Wix Editor, click Settings at the top, then Site Password, choose Password Holders, enter a password and click Save. Wix allows up to 15 characters with no special characters, and says the site-wide option isn't currently available to all users. For one page, open Pages & Menu, click More Actions next to the page, then Settings, the Access tab and Password holders.

How do I make a website private? Put a check in front of it that decides who's visiting: a password, an email whitelist or a sign-in. Hiding it from Google alone, with noindex or an unlisted URL, doesn't keep people out.


So: the host's built-in gate, plus an email whitelist for anyone who'll see more than one round. Round two of a client preview shouldn't start with a new password and a group email.

Gating a single page or a small static site? The password protect an HTML page walkthrough takes you from file to protected link.