Original article was published on Artificial Intelligence on Medium
How to setup personal blog using Ghost and Github hosting
This was originally posted on my personal blog at https://kushajveersingh.github.io/post_008/
You can check my website at https://kushajveersingh.github.io/ as a reference of what the site looks like.
Note:- I am not an expert in website building. I focus on deep learning research, so there may be some things that may not be needed or are not optimal. But in the end I got the site running which is what matter the most for me.
My system info
- Ubuntu 20.04 LTS
- Ghost 3.15.3
- Yarn 1.22.4
- Nodejs 12.16.3
Short summary of what we are going to do.
- Install Ghost locally from source
- Use default casper theme to make the website
- Generate a static site using gssg
- Host the static site on Github
Install Ghost locally and it’s dependencies
- Install NodeJS. (v12 is the recommended for Ghost)
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash
sudo apt install -y nodejs
2. Install Yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.listsudo apt update && sudo apt install yarn
3. Install Ghost from source. (The official setup guide can be found here. Note: Replace
KushajveerSingh with your Github username.
git clone --recurse-submodules email@example.com:TryGhost/Ghost
4. This is a hack. If you follow the official setup guide then you would have forked the Ghost repo and added that as your upstream in the previous step.
I skipped that step, as I was having some problems with that. Instead, I deleted the
.git folder and initialized a new github repo for version control.
So go the main Ghost folder and delete
.github folder. Then go to
core/client and delete the
.git folder and submodule file and you are done.
5. Install dependencies (In home directory of
sudo npm install
sudo npm install -g knex-migrator
6. Make your Ghost folder a github repo.
a)Goto Github and create a new repo where you want to store the
Ghost folder run these commands to push it to github.
git add -A
git commit -m 'initial commit'
git remote add origin firstname.lastname@example.org:KushajveerSingh/Ghost.git
git push -u -f origin master
Create the website using Ghost
npm start to start the Ghost server. This will open the server at
http://localhost:2368/ghost from where you can start creating your website.
Now create your website locally, and when you are done move to the next step.
This is the tool that we will use to get a static site out of our Ghost site. You can check the official github repo of the package for more details on the usage.
To download the package run
npm install -g ghost-static-site-generator. If you get errors run this command again. I ran this command twice and it worked. Maybe try
sudo if it still not works.
Now you can create your static site using
gssg --url=https://kushajveersingh.github.io/ and it will create a
static folder in your current directory, from where you can copy the contents to your
Automating the above process
To automate the complete process and ensure that my
Ghost repo and
.github.io repo are in sync, I created this script.
You need to change only
url as per your requirements.
./generate_script.sh "initial commit"
Your repositories will be pushed to Github with the provided commit message.
You can check my other posts also: