Hosting a static website on GitHub Pages is a great way to build a professional web presence for free, but using a custom domain gives it that extra touch of professionalism. Here’s a detailed guide on how to set up a custom domain on GitHub Pages.
Before you can configure GitHub Pages, you’ll need to purchase a domain name. You can buy domains from various registrars such as Namecheap, GoDaddy, or Google Domains.
Once you’ve registered the domain, you’ll have access to its DNS settings, which is crucial for the next steps.
After acquiring your custom domain, you'll need to configure DNS records to point the domain to GitHub’s servers. Here’s how:
More detailed instructions on configuring CNAME records can be found on GitHub Pages Documentation.
Now that your domain is pointing to GitHub Pages via DNS, the next step is to link your GitHub Pages repository to the domain.
Once saved, GitHub will automatically create a CNAME file in the root of your repository, which ensures that GitHub Pages knows your custom domain is linked to your site.
For more detailed information on this step, check out GitHub's official guide.
After setting up your custom domain, it's recommended to enforce HTTPS for security reasons. GitHub Pages provides a free SSL certificate through Let's Encrypt.
This ensures that visitors access your website securely via https://. More information on HTTPS setup is available in GitHub Pages Documentation.
DNS changes typically take time to propagate across the web, so your custom domain may not work immediately. It may take up to 24-48 hours for the changes to take effect. You can use online tools like DNSChecker to monitor the progress of DNS propagation.
If your custom domain isn’t working as expected, here are a few common troubleshooting tips:
For more detailed troubleshooting, GitHub’s official help page provides extensive information.
By following this guide, you should have your custom domain set up and working on GitHub Pages in no time!