How Blog
I like free stuff.
I also like using tools I am familiar with. In many cases it can lead to good and simple solutions.
This is why I chose Github Pages for my blog -
- I wanted to keep the posts in a Github repo anyway
- To have a backup of the data that is independent of any blog hosting platform.
- To have history, branches for edits, and all that good stuff we all know and love when we code.
- Github offers hosting Github Pages for free
So I am giving it a chance. So far it’s really great - setting it up was quick and easy.
The way it works is you have to go into the repo settings and enable Github Pages, and then choose the branch you want the blog to be published from. Then every new commit to that branch will trigger a Github Action to publish the website.
The only thing I didn’t like is - as a free account, if I want to enable Github Pages for my repo, I have to make the repo public. That’s OK and I don’t mind it, but I don’t want my drafts to be visible to anyone before I publish them.
The way to manage drafts in a repo like this is to have another branch, make all the edits there,
and merge it to main
when I want to publish.
But there is no such thing as a “private branch” in a public repo.
But I figured - I can “fork” my own repo, and make the fork private, and put my drafts in there. That’s a nice idea except Github doesn’t allow you to fork a repo to the same account.
So I found a workaround - I created a new private repo, and set it up as another remote in my local git repo.
git remote add draft git@github.com:Malkiz/malkiz.github.io-private.git
Now I can create a branch and set its remote tracking branch to be on the draft
remote -
git checkout -b my-draft
git push -u draft
So now I have everything I wanted -
- I can work on my draft in my branch.
- Back it up to a private git repo.
- Merge it to the public repo to have it published when I’m done.
- Feel very clever for finding a way to “cheat the system” :)
All while using a tool I already know (Github), for free, without even having to set up a deployment process.