Pushing Ghost to Free Github Hosting
So after blogging the first week of camp on Jekyll which is a great tool for blogging, I decided to move my blog over to Ghost. I've heard a lot about Ghost as the node.js built, strictly-blogging platform, and have always wanted to give it a go. While Jekyll was fun to use, it just didn't seem powerful enough for what I wanted to accomplish. And having worked extensively with Wordpress, I didn't want to set up a full wp blog just because I was bored of the platform and wanted to try something that integrated more closely with github pages. What I loved about Jekyll was that it is done all through Github and is super easily hosted on Github pages. So when I decided to move to Ghost, I wanted to figure out how I could similarly host it on Github and also use it to make changes.
So here is my super simple guide on how to set up a Ghost blog, host it on Github, and how to update it. This is an instruction set for Mac OSX.
Step 0: Initial Setup (in terminal)
You'll need to have pip, node.js/npm, and wget so if you don't have those installed, you can do it with brew. And if you don't have brew installed you can install it with:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then to install pip,node.js/npm and wget you can do this:
easy_install pip brew install wget brew install node
And lastly, we'll have to get buster. Buster is actually written in Python, and it takes a Ghost blog and changes it into static pages so that you can upload it to Github.
pip install buster
Step 1: Download Ghost
Next, download ghost and unzip it into whatever directory you want to use. Once it's installed, in your terminal, cd into that directory. Then you will have to install and run ghost. Once you're in the folder that ghost was installed into, type these commands:
npm install npm start
This will start a local instance of your ghost blog here: http://127.0.0.1:2368/ghost. If you're not automatically redirected, you can click that link. Once there, set up your blog, and add a post or something to check.
Step 2: Create a Github Repo
Now go to your github account and create a new repo at yourname.github.io with your account name going where I wrote "yourname", duh! If you already used your single github pages allowance, then you'll have to either create a new github account to host it or change that repo name to something else (it will no longer be hosted on github accounts then..) to make room for your ghost blog to be hosted there.
Step 3: Setup Buster
Now, open a new terminal window. Create a new folder/directory wherever you would like to put the new static pages that buster will create. I just created a new directory called "ghost-live", ironic I know. Just like before, cd into that directory and run this command:
When you run this, it will ask you to put in your repo address, which will be something like this: https://github.com/yourname/yourname.github.io.git. Then, you'll have to generate the static pages with this command (Buster basically scrapes through your site following links on the home page and puts it together into a package).
buster generate --domain=http://127.0.0.1:2368
Step 4: Push to Github
You have now created a static version of your blog that you can host on Github. Now we just have to push it there. When you generate the blog, it creates or overwrites a folder named static. So first go into that folder:
Then add, commit, and push your changes to your Github page!
git add -all git commit -m 'Initial commit' git push
Wait a few seconds (it may take a few minutes... but that is rare), and go to the page and see if it's running at yourname.github.com.
Step 5: Workflow
So now that my blog is all setup, my workflow looks something like this:
1. Go into my ghost installation and:
2. Then go to http://127.0.0.1:2368/ghost and write a new post.
3. Then go into my static pages folder root (not into the static directory) and run:
buster generate --domain=http://127.0.0.1:2368 cd static git add . git commit -m 'Initial commit' git push
4. Check site to see if it updated.
This might seem like a lot, but it's actually really quick, especially if you set up an alias in your .bash_profile for the buster generate command.
I also blogged about how to edit your bash profile to easily accomodate buster. Check it out here.
Please email me if you have any questions!
What I Learned Today:
If you get a new mac computer, make sure xcode command line tools are installed to avoid hours of weird debugging!