Password protected pages

While building your site, you may want to publish it to show to some people, but not the entire world. With some javascript, you can allow only visitors who have a selected password to view your site.

Within the page settings sidebar, create a new snippet. Paste the following code into the snippet:

    function password() { var userPassword; var myPassword = "hello";
        userPassword = prompt("Enter the password:");
        if (userPassword === myPassword) {
        } else {
            alert('Incorrect'); password();

Instead of "hello", you can change the password to anything you'd like. You can also change the text displayed to visitors in the prompt. Make sure to only enable this snippet for live pages and place it in the <head>. Add the snippet to your page and view the live page. You should now see a prompt from the browser to enter the password, keeping all unwanted eyes away from your site.

Note that this is not a truly secure way to protect your site or page content. Any technically-savy visitor can access a page's source code and easily find your password. Please do not include any sensitive data.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us