In my very first post on this blog I mentioned that my blog is running / built by Hugo hosted on Github Pages.
Back then I found a Github action that I simply took over because it just worked for me. You can check it out in this Gist. Like I said, I haven’t really configured much for this, but it seems to be a bit overcomplicated.
Then there’s another thing that makes it somewhat complicated. I wanted to get at least a few stats. Github Pages doesn’t provide anything useful in their free tier. So I cheated a bit and proxied my blog through Cloudflare.
You can use a custom domain by simply using a CNAME pointing to your
*.github.io domain. First of all, this would not work since
you usually cannot use a CNAME on an apex domain like I do. But Cloudflare makes it work anyway. Thanks to
CNAME flattening. But then there’s a problem: Github performs a DNS lookup
to make sure the custom domain’s DNS is responding with Github’s IP addresses. And another problem occurs: Cloudflare doesn’t allow
proxying for CNAMES.
Interestingly: Github doesn’t care if the DNS check fails or not. You can enter a custom domain and it will keep displaying the “check in progress” message but yet it already seems to work anyway.
To fix the problem with Cloudflare not allowing me to proxy the page I simply went ahead and entered the 4 static IPs Github uses for Pages and entered them manually in my DNS Configuration. Done.
If you think this sounds like quite some hacky solution: yep, me too.
Not sure if I either ignored it or simply didn’t see it, but Cloudflare provides their own Pages solution and it seems to be much more idiot-proof than what I was using.
There are 4 easy steps to get everything up and running.
- Create a new Pages application
- Link said application via Github authentication
- Select the repository that should be used for your page
- Choose your framework from a long list
Adding a custom domain is easy as well. You simply go back to your newly created page and choose one of your existing domains in the “Setup a custom domain” tab. From here, Cloudflare will automatically create a new CNAME record on your custom sub-/domain.
That’s it. By default everything is automatically hooked up to my Github repo and everytime I push a new commit to the configured “production” branch, a new build is going to be triggered and automatically deployed.