Private Mode: How and where to use the handle for {{#is "private"}}

Latest version.
Into what file do I put the code for adding content to the private page? Perhaps @John or @Kevin knows more? According to the documentation, we can use “private” for the private page shown for password protected sites.


{{#is "private"}}


{{#is "private"}}
output something special for the private page ...
output something different on all other pages ...
{{/is}} you can override the private login template by adding a private.hbs file to your theme, you can see the default private.hbs template here.

{{#is "private"}} use-case is quite narrow, if you’ve overridden the default private.hbs file and you use other template files from there that are also used in other contexts then it’s possible to have {{#is "private"}} in those generic partials or layouts to modify their behaviour.

Ah, okay. Thanks! Should I just copy the default.hbs file and rename it?

That’s up to you and how you want the private mode login screen to look. If you do copy+rename default.hbs you’ll need to copy the form the default private.hbs template for it to work.

Just in case there’s any confusion, private mode is nothing to do with members. It’s there as a basic (and not intended to be secure) mechanism to hide your site whilst it’s under development or when operating in headless mode. For those reasons it’s not all that typical to do anything with it in themes.

Yep, got it. Thanks. I was merely after adding content, making sure potential visitors understand that it’s under development and not yet ready.

Since I found no option in the settings or could make injections, I had to ask.

Thanks for your help.

@Kevin FYI: I copied the template from the Github source and placed the file in the theme folder. I then moved it into the partials folder since I was unsure of where it should live.

Either way; none of the design changes take effect when activating private mode.

It should live in the top level of your theme as private.hbs, it’s not a partial but a full template.

How are you making the changes, uploading a zip via the admin area or making changes directly in your theme folder? If it’s the latter then you’ll need to restart Ghost after adding the template file for it to be picked up.

I did not restart. Thank you for your help and fast response. Now I know that I need to restart. Is a restart required if installing a new theme with the file already there?

No, the restart is only required if modifying theme files directly. Handlebars files are heavily cached and changes to existing files are picked up in development mode but new files aren’t recognised without restarting.

Installing or activating a theme via the admin UI or the API will never need a restart.

Thanks a lot. I truly appreciate it. Give me some time to properly learn Ghost and I will be more than happy to contribute any way I can.

@Kevin Thanks again. It’s coming along pretty nicely. Enjoy your week!