Today I began using GitHub Pages to host my blog. It is created using Middleman – a static site generator. I followed the guide provided by GitHub but it left out a few details so here is a tutorial on how to setup GitHub Pages, a custom domain, and Middleman deploys.
Setting up GitHub Pages
- Create a repository using the format requested by GitHub where
usernameis your GitHub username.
- Create a branch called
sourceand place your source files there. GitHub Pages requires that your static files be placed in
git checkout -b source
Setup custom domain with GitHub Pages
As outlined by the GitHub documentation
- Create a
CNAMEfile with your custom domain in the source directory of your source branch.
I decided to go with using a custom subdomain for the various reasons provided by GitHub which include access to their CDN, being immune to changes in IP addresses for GitHub, and faster load times.
- Configure a CNAME record with your DNS provider.
- Disable Jekyl processing by creating
.nojekyllin the source directory of your source branch.
Setup Middleman Deploys
- Add middleman-deploy to your Gemfile
- Activate the extension in
activate :deploy do |deploy| deploy.method = :git deploy.branch = 'master' end
- To deploy to GitHub Pages, from the
middleman build middleman deploy
The statically generated files will be pushed to your remote master and live within a few minutes.