"Coming Soon" page + private blogging

Followup: The above described changes appear to have worked. Here’s a summary for anyone who want’s to replicate what I did:

  1. Download a copy of your active theme from your site’s admin backend, at the bottom of www.yoursite.com/ghost/#/settings/design and unzip it.

  2. In this downloaded copy of your theme, save a copy of private.hbs, https://raw.githubusercontent.com/TryGhost/Ghost/master/core/server/apps/private-blogging/lib/views/private.hbs , then open it in a text editor.

  3. On line 26, add these id and style attributes to hide the password form:
    <section class="gh-flow-content" id="private" style="display:none">.

  4. I put my “Coming Soon” content just above this <section> tag, but it can go anywhere except in that section. It can be a whole page or just a single line, like <h1 style="text-align:center; margin: 25vh 5%">YourSite.com is coming soon!</h1>

  5. At the end of the template, just above </body>, add this link:
    <a style="position:fixed; z-index:9999; bottom:0; left:0; line-height:1; font-size:24px; cursor:pointer" onclick="document.getElementById('private').style.display='block'">&nbsp;&nbsp;</a>
    This will create an invisible link in the lower-left corner of the page, which you can click to unhide the password form.

  6. Re-zip your theme folder and upload it via the same admin panel from which you downloaded it.

If you want the URL redirect path to be /coming-soon/ (or whatever you like) instead of /private/, make the two edits described in the previous posts. I did it via SSH:

ssh root@your-domain-or-ip-address
su - ghost-mgr
# Your file paths may vary:
cd /var/www/ghost
# Edit the files with your preferred editor:
nano /var/www/ghost/versions/2.9.0/core/server/apps/private-blogging/index.js
# In line 7 of index.js, change 'private' to 'coming-soon'. Save changes. Then...
nano /var/www/ghost/versions/2.9.0/core/server/apps/private-blogging/lib/middleware.js
# In line 12 of middleware.js, change '/private/' to '/coming-soon/'.
# Save changes. Then activate the changes by restarting Ghost...
ghost restart
# I assume the site was down during the restart, but it only took a few seconds.

The redirect URL is still a bit ugly because of Ghost’s added query string, /coming-soon/?r=%2F, but it’s tolerable. If I had more time to waste I’d figure out how to lose the query. :)

Thanks again, @egg, for your support.

PS: This approach could also be used for taking a site offline temporarily for maintenance, major upgrades, etc.

3 Likes