When you publish a site with GitHub Pages, the default address will look something like this: https://<username><repo name>. For example,

If you’d like to replace the default address with your custom domain, such as , follow this tutorial!

What you will get in this tutorial

  • Setting up a custom www subdomain, such as, for your GitHub Pages
  • having the apex domain, such as, automatically redirect to

What you need

Step 1. Setup in your Github Repo

  • Go to Settings > Pages > Custom domain, and add you custom domain name, such as “”

    example image

Step 2. (Optional) You can skip this step if you are NOT using a site generator, such as fastpages, or Jekyll

If you are using fastpages.

Step 3. Let your custom domain point to your GitHub Pages

  • Go to your google domain registrar and select your domain.

  • Go to the DNS tab

    example image

  • Under the Resource records section, click Manage custom records

    example image

  • Create a CNAME record that points your www subdomain to <your_github_username>

    example image

    • Do NOT include the repository name, such as If you include your repository name in the CNAME record to your DNS provider, you’ll get the below message at your GitHub Settings > Pages > Custom domain

      example image

  • Create an A record that points to the IP addresses for Github Pages.

    example image

    • IP addresses in the screenshot
    • Check here if there’s an update in the IP addresses.

  • Open Terminal to confirm that your DNS record configured correctly

    • For CNAME records, do

        dig +nostats +nocomments +nocmd
      • You should get

          ; <<>> DiG 9.10.6 <<>> +nostats +nocomments +nocmd
          ;; global options: +cmd
          ;	IN	A
 3312	IN	CNAME
 3312 IN	A
 3312 IN	A
 3312 IN	A
 3312 IN	A
    • For A records, do

        dig +noall +answer -t A
      • You should get

         ;; global options: +cmd	928	IN	A	928	IN	A	928	IN	A	928	IN	A

Step 4. Enable HTTPS for you GitHub Pages

  • Go to your github repository settings page, under Settings > Pages, remove your custom domain and save.

  • Then add it back and save again.

  • Now you should be able to check the Enforce HTTPS checkbox

    example image

  • Note: DNS changes can take up to 24 hours to propagate.

That’s it! Your website should be publishing at your custom domain now!