I will be using centos logging in through ssh. I assume you have git installed. If not simply issue this command:
yum install git
To install new themes in ghost we need to put the new themes in the ghostdir/content/themes
directory. So first thing’s first let’s go there.
[ahmed@amayem ~]$ cd /var/www/ghost/content/themes/
You should be running ghost using its own user, which is probably called ghost
. Since we will be modifying ghost its best if we switch to the ghost user so we don’t have to keep sudoing and messing up file ownership.
[ahmed@amayem themes]$ sudo su ghost
Cool we are now acting as the ghost user. Let’s check what we have in the directory.
[ghost@amayem themes]$ ls -la
total 12
drwxr-xr-x 3 ghost ghost 4096 Mar 29 01:54 .
drwxr-xr-x 6 ghost ghost 4096 Mar 29 01:54 ..
drwxr-xr-x 3 ghost ghost 4096 Apr 5 03:27 casper
This is just so we can compare the directory after we load the theme, in case something ‘weird’ happens and something else is added to the directory.
Next we need to get our new theme into this directory. I would like to install the theme ghostwriter which is available on github here. Notice the textbox on the right that says HTTPS clone url
with a url under it. We want that url. Copy it then go back to the console and use it as follows:
[ghost@amayem themes]$ git clone https://github.com/roryg/ghostwriter.git
Cloning into 'ghostwriter'...
remote: Reusing existing pack: 473, done.
remote: Total 473 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (473/473), 447.07 KiB, done.
Resolving deltas: 100% (231/231), done.
Great, now let’s check that its there and nothing was changed.
[ghost@amayem themes]$ ls -la
total 16
drwxr-xr-x 4 ghost ghost 4096 Apr 6 18:34 .
drwxr-xr-x 6 ghost ghost 4096 Mar 29 01:54 ..
drwxr-xr-x 3 ghost ghost 4096 Apr 5 03:27 casper
drwxrwxr-x 4 ghost ghost 4096 Apr 6 18:34 ghostwriter
Ghostwriter is now available as a directory and casper’s last changed date hasn’t changed, which looks good. Of course the date for the current directory has changed as we just changed it. Also notice how the ownership all goes back to the ghost user. One thing does seem odd which is the permissions of ghostwriter. It seems the ghostwriter directory has an extra write permission for the group. The group just happens to be ghost also which has one user in it: ghost, so there isn’t a big problem here. If you would like to be consistent you could always issue the following command:
[ghost@amayem themes]$ chmod g-w ghostwriter/
[ghost@amayem themes]$ ls -l
total 8
drwxr-xr-x 3 ghost ghost 4096 Apr 5 03:27 casper
drwxr-xr-x 4 ghost ghost 4096 Apr 6 18:34 ghostwriter
There you go, now it all looks consistent.
Let’s go inside the ghostwriter directory and see what we have.
[ghost@amayem themes]$ cd ghostwriter
[ghost@amayem ghostwriter]$ ls -la
total 188
drwxrwxr-x 4 ghost ghost 4096 Apr 6 18:34 .
drwxr-xr-x 4 ghost ghost 4096 Apr 6 18:34 ..
drwxrwxr-x 5 ghost ghost 4096 Apr 6 18:34 assets
-rw-rw-r-- 1 ghost ghost 1771 Apr 6 18:34 changelog.txt
-rw-rw-r-- 1 ghost ghost 3232 Apr 6 18:34 default.hbs
drwxrwxr-x 8 ghost ghost 4096 Apr 6 18:34 .git
-rw-rw-r-- 1 ghost ghost 2757 Apr 6 18:34 index.hbs
-rw-rw-r-- 1 ghost ghost 1088 Apr 6 18:34 LICENSE.txt
-rw-rw-r-- 1 ghost ghost 47 Apr 6 18:34 package.json
-rw-rw-r-- 1 ghost ghost 555 Apr 6 18:34 page.hbs
-rw-rw-r-- 1 ghost ghost 1875 Apr 6 18:34 post.hbs
-rw-rw-r-- 1 ghost ghost 1627 Apr 6 18:34 README.md
-rw-rw-r-- 1 ghost ghost 138698 Apr 6 18:34 screenshot.png
-rw-rw-r-- 1 ghost ghost 748 Apr 6 18:34 tag.hbs
Looks similar to the casper directory, but notice the .git
directory. That is ther because we loaded the theme using git. You can delete it or keep it, it won’t really make a difference as long as you don’t plan to use git again with regards to this theme.
Now we need to restart ghost. I am using forever so it will look like this:
[ghost@amayem casper]$ forever list
info: Forever processes running
data: uid command script forever pid logfile uptime
data: [0] v7zw /usr/bin/node /var/www/ghost/index.js 914 5086 /home/ghost/.forever/v7zw.log 1:15:7:6.416
[ghost@amayem casper]$ forever restartall
info: Forever restarted processes:
data: uid command script forever pid logfile uptime
data: [0] v7zw /usr/bin/node /var/www/ghost/index.js 914 5086 /home/ghost/.forever/v7zw.log 1:15:7:10.505
Go to your ghost admin panel. Go to settings and the theme should appear. Enjoy.
References
The ghost docs.