Publishing GitHub Pages to a custom (.ca) domain
Assume that you bought the domain acanadiandomain.ca from canspace.ca or from any registered domain registrar at CIRA The instructions below are to setup both the apex and subdomain
At GitHub
- Follow the instructions to setup a www subdomain
- Ensure that you have added ac custom domain to your GitHub Pages site
At Canspace
- Once you have bought acanadiandomain.ca domain from Canspace log in and follow the instructions to manage your DNS entries
- Specifically create a zone which in this case would be acanadiandomain.ca
- Then edit the zone to add records. There may be some default records already setup
- You will want to remove the CNAME entry for www.acanadiandomain.ca aliasing to acanadiandomain.ca
- For a preliminary setup let’s setup the www subdomain only
- Add a CNAME entry for www.acanadiandomain.ca to YOUR-GITHUB-USERNAME.github.io
- Add an A entry for acanadiandomain.ca to the IP addresses listed here
- Remove the A entry for the default ipadress provided by canspace.ca because you do not need their domain forwarding
- You may want to check if your DNS provider supports ANAME or ALIAS. Could not find entries for that while creating DNS entry records in canspace.ca so I assume that it does not.
- This is how the final setup may look like
# check if CNAME entries are correct
$> dig www.acanadiandomain.ca +nostats +nocomments +nocmd
;www.acanadiandomain.ca. IN A
www.acanadiandomain.ca. 14400 IN CNAME YOUR-USERNAME.github.io.
YOUR-USERNAME.github.io.. 672 IN CNAME sni.github.map.fastly.net.
sni.github.map.fastly.net. 26 IN A 151.101.XX.XXX
# the above may take a while
# you can check dns propagation on the web at
# https://dnschecker.org or https://www.whatsmydns.net
# you can also query a particular nameserver for example google to check propagation
$> dig @8.8.8.8 www.acanadiandomain.ca +nostats +nocomments +nocmd
# check if A entries are correct
$> dig +noall +answer acanadiandomain.ca
acanadiandomain.ca. 11901 IN A 192.30.252.154
acanadiandomain.ca. 11901 IN A 192.30.252.153
TroubleShooting
- Check at the minimal if your own dns has the right settings propagated
- Shift+f5 to force a refresh in your browser.
- You may need to close your browser or clear your cached depending on your setup.
- Try incognito/private modes in your browser
- Add the http cache expires header to your html page
- If the CNAME and A entries are correct then github will automatically set up the redirects appropriately