Skip to content

Ghost Tips & Tricks

Tips, scripts, and tricks on different things related to Ghost.

When working on the server, always make sure to have a backup.

Access DigitalOcean Droplet

This assumes you already configured the connection between your computer and DigitalOcean. Change your droplet IP.

ssh root@

Multiple Ghost Installations • DigitalOcean

I assume:

  • You are logged in to your droplet using SSH from the command line
  • Your domain name is ready and connected to the droplet IP
  • You know what you are doing :)

➊ You need the current MySQL host, username, and password.

cd /var/www/ghost/

cat config.production.json

Take notes of them. You will use them later in steps 3 and 5.

➋ Create a website directory, for example, ubud.

cd /var/www/
sudo mkdir ubud
sudo chown ghost-mgr:ghost-mgr ubud/

➌ Login to MySQL and create a new database

sudo mysql -u root -p

GRANT ALL PRIVILEGES ON ubud.* to 'ghost'@'localhost' IDENTIFIED BY '7d150600c49e7c5860be7ce03d4f8df67259176738d926ec';
  • ghost → database user
  • localhost → database host
  • 7d150600c49e7c5860be7ce03d4f8df67259176738d926ec → database password

➍ Switch to the ghost-mgr user

sudo -i -u ghost-mgr

➎ Install Ghost and follow the installation steps

cd /var/www/ubud/
ghost install

Update Multiple Installation on the Same Droplet • DigitalOcean

for d in /var/www/*/ ; do (cd "$d/" && ghost update); done

Modified version of Daniel script.

Renew Let’s Encrypt SSL Certificate • DigitalOcean

/root/ --force --renew --home /etc/letsencrypt --domain --webroot /var/www/ghost/system/nginx-root --reloadcmd "nginx -s reload" --accountemail

Replace with your domain and with your email.

Download & Upload Images • DigitalOcean

When you want to download the website images from one server and upload them to another server. Change the IP and paths.


scp root@ /Users/ahmadajmi/Desktop


scp /Users/ahmadajmi/Desktop/ root@

Zip and Unzip Images

zip -r images

unzip -o

Fix Images Upload Error 500 • DigitalOcean

sudo chown -R ghost:ghost ./content

Make your Ghost website embeddable in an <iframe>

cd /etc/nginx/sites-available/



➋ Add:

add_header X-Frame-Options "ALLOW-FROM *";


➌ Ex:

location / {
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header X-Forwarded-Proto $scheme;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header Host $http_host;

  add_header X-Frame-Options "ALLOW-FROM *";

---sudo nginx -s reload


Quickly Edit a Post • Source

Append /edit to your post URL, and you will be redirected to the post editor. →

Of course, you need to be logged in.

Chrome Extention — Ghost Edit Button

Output How Many Posts in Total and How Many Paid • Source

{{#get "posts" limit="1" as |posts pagination|}}
  {{}} total posts

{{#get "posts" limit="1" filter="visibility:public" as |posts pagination|}}
  {{}} public posts

{{#get "posts" limit="1" filter="visibility:-paid" as |posts pagination|}}
  {{}} free posts

{{#get "posts" limit="1" filter="visibility:members" as |posts pagination|}}
  {{}} members posts

{{#get "posts" limit="1" filter="visibility:paid" as |posts pagination|}}
  {{}} paid-members-only posts

Handlebars Comments

You can add comments to Ghost theme Handlebars files (.hbs) by wrapping the content you want to hide within {{!-- --}}.

For example,


or in one line as:

{{!-- <h1>Heading</h1> --}}

Commenting code is helpful if you want to edit the theme and don’t want to remove the lines but keep them fur future reference.

Use code TODAY for 10% off