Setting up Ghost locally and hosting with GitHub - the macOS way
I guess most of you heard about Ghost - not the spirit kind, a blogging platform. Beautiful, feature rich and easy to setup. In this tutorial I will try to show how to setup Ghost blog in macOS (obviously local installation) and host that blog with GitHub pages, a static website hosting which runs directly from your GitHub repository. Sounds confusing? Well, everything will be clear as water after you finish reading this tutorial. I will not discuss how GitHub works or how to open/manage repository there, because I hope you can do it yourself. Do some search over Google and you will find tons of information related to this. One thing to remember, you need to have:
*Xcode CLI tool
*Homebrew package manager,
*Node (version 4.x LTS),
*wget,
*python and buster installed in your machine before start working around. Now, lets move ahead...
Step-01 (Setting up Ghost)
First of all, download latest version of Ghost from here and extract it somewhere in your machine.
unzip ghost-xxx.zip -d ghost-blog
you can change the folder name (ghost-blog) to anything else as your wish. Now enter inside that folder and give following commands:
npm install --production
npm start
Ghost instance is running now and you can login into Ghost dashboard by pointing your browser to: localhost:2368/ghost/
make necessary changes there as per your choice. You can write new post, add static pages, add/remove themes and everything from there.
Step-02 (Hosting with GitHub)
Firstly, create an empty folder anywhere in your machine, you can create it into same place where you put your Ghost blog folder. Suppose you give it a name like- blog-live. Enter inside that empty folder and give following command:
buster setup
it will ask for your GitHub URL. Input your repository HTTPS clone URL - "https://github.com/username/username.github.io.git"
where 'username' means your GitHub username. Press enter to continue. Now you need to give following command:
buster generate --domain=http://localhost:2368
you can see a folder called 'static' has been created. Navigate to that folder and give following commands:
git add --all
git commit -m "blog is ready or whatever"
git push --set-upstream origin master
Now you can go to your GitHub pages website and check if your blog is live or not.
Step-03 (Making changes)
Now we are at final stage. It's normal that you will write posts regularly, keep changing themes blah blah. So you need to ensure that changes you have made locally effects your GitHub hosted website. It's a manual process I'm afraid, but not something hard. Whenever you make any changes in your Ghost blog locally, no matter what kind of changes they are, you need to navigate to the folder which you have created in Step-02. Then give following command again:
buster generate --domain=http://localhost:2368
after that enter inside static folder again and give following commands to push your changes into GitHub:
git add --all
git commit -m "some changes"
git push --set-upstream origin master
After you have finished making changes in blog and push those in your repository, you can shutdown local Ghost instance. But remember, never ever shutdown Ghost instance before pushing changes. Finally, share your thoughts, ideas, stories, photographs etc. etc. through your new GitHub hosted Ghost blog with friends and family, because sharing is caring.
Hope you guys will give this tutorial a try. Happy blogging!