Did you know that you can host your website on GitHub? This blog is currently hosted for free on GitHub. You can do this as simple as creating a GitHub repository.
This article shows how to add a custom domain purchased via GoDaddy to the GitHub repository that contains the website.
Purchase a domain from GoDaddy
Open an account with GoDaddy and purchase a .com, .net, .etc domain.
In our case we’ll purchase vmasoft.net
Create the GitHub pages site
Open an account with GitHub. If you already have a github account, you can use that one.
On you GitHub account, create a new project repository: E.g. vmasoft
Create your site in a local folder. At minimum, create only 1 page named index.html
Push the local files into the GitHub repository. There are multiple ways to push files into the GitHub repository. If you prefer the command line you can do via git, like in this example:
git init git add . git commit -m "first version" git remote add origin https://github.com/mveteanu/vmasoft.git git push -u origin master
Go to GitHub repository settings, and locate the In the “GitHub Pages” section. Select “master branch” from the Source combobox to allow your repository behave like a website. Hit “Save”.
Test your website by navigating to the displayed Url. In our example, this will be: https://mveteanu.github.io/vmasoft/
Configure the custom domain in GitHub
In the same “GitHub Pages” section, populate the “Custom domain” textbox with your domain. GitHub recommends using a www subdomain as your custom domain.
In our case this will be:
Of course, you can use other subdomains, or no subdomains at all. You can find more information about supported custom domains here on GitHub.
GitHub has this warning:
“Warning: We highly recommend adding your custom domain to your GitHub Pages site’s repository before configuring your domain name with your DNS provider.”
Set-up A and CNAME records in GoDaddy
Go back to GoDaddy and enter the “Manage DNS” section for your domain.
To set up the apex domain, such as vmasoft.net, we need to configure two A records with GoDaddy.
The A records will point to the following two IP addresses as required by GitHub and explained here
To set up the www subdomain, such as www.vmasoft.net we need to configure a CNAME record with GoDaddy. In order to take advange of GitHub CDN, we will have to point the www subdomain to GitHub account address.
At this point, the GoDaddy DNS records should contain the following:
NAME TYPE VALUE @ A 220.127.116.11 @ A 18.104.22.168 www CNAME mveteanu.github.io
Note: Other entries may be already pre-populated. Don’t worry about those.
Test your new domain
Wait a few minutes (or hours) for the changes to propagate.
Test your new website / domain. E.g. http://www.vmasoft.net
If you have access to a Linux machine you can use the dig command to check the DNS settings. It should look like this: