How to Install Ghost & Host on Github

I just moved from blogspot to Ghost bloggin platform. Mainly because of its simplicity and how minimal it is. I'm using the self-hosted option as I have to write posts on my localhost instead of going to Ghost website itself because its free. Additionally, because I like doing things the hard way :D That's how I roll.

Using Github Pages to host my blog is free and convenient. There is a lot that can be experiment here such as installing themes, plugins etc because it is open source. I write most of my posts in Markdown format because it looks more readable in raw and I can write faster. If you are one this kind, you would want to try Ghost to blog.

This guide uses Ubuntu 14.04 as a prerequisite.

Installing Dependencies

Install node.js and npm.

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

Download and install Ghost. Checkout this link for latest release and replace wget command.

wget "https://ghost.org/zip/ghost-0.4.2.zip"
unzip ghost-0.4.2.zip -d ghost
cd ghost
cp config.example.js config.js
npm install

Start Ghost in 127.0.0.1.

npm start

Navigate to 127.0.0.1:2368/ghost for your Ghost Admin panel.

Create a new post if you'd like to.

Hosting on GitHub Pages

Install Git and setting up an account for git command environment. Please create an account on Github first before doing so.

sudo apt-get install git
git config --global user.name "YOUR NAME"
git config --global user.email "YOUR EMAIL ADDRESS"

Go to Github.com and create a new repository. Name it something like yourname.github.io. This will be your Github static website URL.

After that, create a new branch called gh-pages. This branch will host your static webpage.

Configuring Buster

Buster is a tool for generating a static site for Ghost. You can't literally push your Ghost source code into your repository as Github Pages won't render it. Instead, create a static webpages in order for Github Pages to host. There will be no admin backend for this. You'd want to write your posts on 127.0.0.1.

Install pip. A python package management.

sudo apt-get install python-pip python-dev build-essential
pip install --upgrade pip
sudo pip install --upgrade virtualenv 

Install Buster via pip

pip install buster

Generate Ghost Static Site via Buster

Start your Ghost blog on 127.0.0.1 by npm start. While it is still running, create a new directory outside of your Ghost directory and call it blog-static or something. cd into it.

Setup Buster.

buster setup

When prompted, enter the address of the GitHub repository URL you just created.

Start generating static site.

buster generate --domain=http://127.0.0.1:2368

This will generate a static site based on already running Ghost on 127.0.0.1 under a newly created directory called static. Switch into the subfolder by cd static and do the following to push static site to your Github repository.

Inside blog-static/static dir,

git add --all
git commit -m 'commit message'
git push -u origin

Alternatively, you can just skip the git command and use buster deploy in the static directory and buster will upload it.

Adding a Custom Domain

  1. Buy a domain (eg. http://domain.com)
  2. In A Records, point domain.com to 192.30.252.153 or 192.30.252.154
  3. Add a CNAME Records pointing subdomain such as www.domain.com or blog.domain.com to your *.github.io repository.
  4. Push a CNAME file in your repository using the following command: buster add-domain <domain here>. This will create a file called CNAME in static/ folder.
    • Make sure domain doesn't have http:// when adding it
  5. buster deploy

Blogging Workflow

  1. npm start on aimanbaharum-blog/
  2. write posts on localhost:2368/ghost
  3. switch to static dir aimanbaharum-static\
  4. while running buster generate --domain=http://127.0.0.1:2368 (creates static site in /static)
  5. buster deploy on aimanbaharum-static/
  6. Or in static/,
	git add --all
	git commit -m "message"
	git push -u origin

Source:
Show Comments

Get the latest posts delivered right to your inbox.