Hosting static files on your Ghost blog

One thing that initially annoyed me when I switched to Ghost was it provided no "facility" for uploading my personal static files. For example, I wanted my CV on the server so I can link to it from my about page. If you use the DigitalOcean image then you can follow the instructions here to the letter. Other users can use the same instructions but perhaps, on a different file(more on this later).


Firstly you need to login to your Droplet/VPS 😜

Next we open the Ghost Nginx file using nano /etc/nginx/sites-enabled/ghost. I use Vim so feel free to use whatever editor you are confortable with. The file should look like this:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    server_name; # Replace with your domain

    root /usr/share/nginx/html;
    index index.html index.htm;

    client_max_body_size 10G;

    location / {
        proxy_pass http://localhost:2368;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;

Next you add this block after the location / block:

location /static/ {
    alias /var/www/static/;

So we have just created an alias to a folder on the file system. I believe you can alias whatever folder you want. Also, the static folder does not exist by default so I created that.

Restart nginx sudo service nginx restart and ghost sudo service ghost restart preferably in that order.

If I upload a file to /var/www/static/ called cv.pdf and visit, my cv will be served!👏


Hosting static files on your Ghost blog
Share this

Subscribe to Fayimora