Hosting a (simple) blog on GitHub.

Time for some Ghost Busting!

Starting a new blog is quite simple- just register yourself at one of the many blogging platforms and start publishing your blog at blog-name.platform-name.com.

But that isn’t how everyone wants their blog URL to be. (Don’t you feel that geekspecs.wordpress.com is too long?)

GitHub Pages allows users to host web pages on their account, and this is what we’re going to exploit – to have our blog URL as your-name.github.io/blog

Prerequisites: Ghost

Ghost, for the unfamiliar, is just another blogging platform. Ghost is a platform dedicated to one thing: Publishing. One can read more about Ghost here and proceed to download the latest version of Ghost.

The entire documentation is available here. I shall, however, for the newbies, describe the setup. We shall first host the blog on our system and then push it to our GitHub account.

As Ghost is based on Node.js, we first need to install Node. Download your edition of node from here. Next: Extract and install node onto your system. Make sure you are installing v0.10.*

One can verify by running

$ node -v

Extract the downloaded ghost-*.tar to /var/www/ghost

$ unzip -uo name-of-file.tar -d /var/www/ghost

Move to the directory and install Ghost

$ cd /var/www/ghost && npm install –production

Time to initiate Ghost

 $ npm start – -production

Fire up your browser, and visit 127.0.0.1:2368:  This is where you should see your blog. Visit 127.0.0.1:2368/ghost to setup adminstrator for your blog.

Now that we’re done installing Ghost, we need to configure it. One needs to configure the Mail and URL settings of the blog. Visit this, and generate a config.js file. Replace this with the config.js present in /var/www/ghost . Use your favorite text editor to edit the new config.js and set the URL field in the development dictionary as

http://username.github.io

and save the file.

Use either MySQL or SQLite to store your blog articles. In the same config.js, edit the database settings. If you prefer using MySQL, you need to make a database and set the fields accordingly.

Now that Ghost has been set, publish the articles. You should see your blog live at 127.0.0.1:2368. Head over to GitHub and create a new repository named blog.

Time for some ghost busting!

Buster is a brute force static generator for Ghost, i.e. it generates static webpages from your locally hosted Ghost blog. To install Buster, run:

pip install buster

Switch to the ghost directory and run:

buster setup

When prompted, enter the repository address for blog on your GitHub profile. An example would be:

http://github.com/username/blog.git

 Generate static webpages by running the command:

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

Move to the static directory and setup the git thingy.

git add .

git commit -m “Your message here”

git push origin gh-pages

This should push your static directory to blog repository. Using branch ‘gh-pages’ will enable GitHub pages to detect the index.html and generate webpage accordingly.

Fire up your favorite browser and visit http://username.github.io/blog to see your blog live!

After every new article one writes, one must regenerate the static pages and push them time to time.

Though one can easily note the downsides of having such kind of blog, one cannot neglect the new level of comfort and ease that has been bestowed upon them by the Ghost! Also, no need to worry about blog security as there is no online database to manage.

After such tedious work you guys do deserve a demo. Here it is!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s