I have some WordPress development experience and am trying out Ghost for a new project. The private blogging feature is great for building out the initial content prior to going public with the site, but I’d like the main URL – www.example.com – to display a custom, static HTML, “Coming Soon” page instead of redirecting to www.example.com/private/
I’m aware that I could simply customize the private.hbs template with my “Coming Soon” info, and that would work for me if I could change the redirect path to something more friendly than “/private/”, e.g., www.example.com/coming-soon/
Thanks, @egg … Yes, it helps a lot! This will be my first go at server-side javascript coding, so I hope you don’t mind a few more questions:
Aside from the evil of hacking core files, would simply changing line 12 from… const privateRoute = '/private/';
…to… const privateRoute = '/coming-soon/';
…be enough to change the URL to which anonymous users are redirected?
Is there a way to change that constant without modifying a core file?
Would I also need to change ‘private’ to ‘coming-soon’ in line 7 of index.js, here:
On line 26, add these id and style attributes to hide the password form: <section class="gh-flow-content" id="private" style="display:none">.
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>
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'"> </a> This will create an invisible link in the lower-left corner of the page, which you can click to unhide the password form.
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. :)