Oh, that annoyed me more than it should. Yes, it's quite easy to make your custom domain point to your GitHub Pages project, but from the confusing GitHub documentation (too much freaking information) to the annoying first-page Google results, took me a while for everything to work properly.
Now I have my GitHub Pages project working fine over HTTPS with my custom domain on https://drugowick.dev or https://www.drugowick.dev.
So... assuming:
- you already have a custom domain (mine is drugowick.dev)
- you already have a GitHub Pages project (if you don't...
... here are the 3 simple steps to use your GitHub Pages project with your domain:
On your GitHub Pages repository settings (
https://github.com/<your-username>/<your-username>.github.io/settings
) in theCustom domain
field, put your custom domain including the www in the beginning, like so:
Check the box
Enforce HTTPS
(you may have to wait a little for this option to be available).Add the following
Custom resource records
to your Google Domains DNS configuration:
- A set of
A
records pointing to GitHub's IPs. Here you can find the updated IP addresses that should be used. - A
CNAME
record pointing to<your-username>.github.io
and withwww
on the Name field.
Wait a little bit again for everything to work. It will work!
Well... it works for me! =)
Thanks to:
- https://woliveiras.com.br/posts/jamstack-dom%C3%ADnio-personalizado-com-google-domains-e-github-pages/
- https://medium.com/@monarchwadia/github-pages-setting-up-www-subdomain-with-ssl-https-aca9eca371d6
Image from ann_designs por Pixabay
Top comments (7)
Hi Bruno, thanks for the instructions, but how do you overcame NET::ERR_CERT_COMMON_NAME_INVALID error? This is because SSL cert is issued to github. I see that at your site the ssl is yours. Thanks in advance.
Hi, Anthony. Glad that I was helpful so far.
I actually didn't have to overcome any issue. Have you correctly named you repository in GitHub? For free accounts you can only have one GitHub Pages repository.
Also, after configuring the HTTPS option on GitHub and defining the CNAME on Google Domains, it takes a while to work.
Woke up in the morning and it just works. Now, when I look at a cert it says issued to my own domain and issued by Let's Encrypt. Before it was a github cert. How is that working? I did nothing to get a letsencrypt cert. Is that a github's feature?
Glad that it worked!
AFAIK, yeah, it's a Github Pages feature.
Hi I am receiving Issues in enabling HTTPS to my .dev website through github pages as you discussed. Any similar issues that you faced?
Hello!
There was no issues with this particular set of instructions, I only had to wait a few minutes before everything work as expected.
Is there any particular issue that you want to share or the thing just doesn't work at all?
Yes, thank you! This was my exact issue, along with Anthony's (NET::ERR_CERT_COMMON_NAME_INVALID). After about 20 minutes, the site loads with and without 'www'!
Thank you! 🙌🏽