Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Using Your Own Domain Name5:04 with Guil Hernandez
If you've purchased a domain name for your website, you can configure it so that it points to your site hosted on GitHub pages.
- Tips for configuring an A record with your DNS provider
- What is a CNAME record?
- What is an A record?
GitHub IP addresses
- When configuring a custom domain name with GitHub Pages you: create a CNAME containing your custom domain name, point your custom domain's A record to GitHub's servers, then wait for the changes to take effect.
- To redirect a custom domain to your GitHub Pages site, create a CNAME file that specifies the custom domain.
- CNAME stands for 'canonical name'; it's a type of record used for creating aliases for domains.
- In the CNAME file is where you specify that a domain name is an alias for another domain.
- When creating the CNAME, you need to name the CNAME file in all uppercase letters.
- The 'www.' in the domain is optional in the CNAME.
- The CNAME can contain only one domain.
- An A (Address) record points a domain to one or more IP addresses.
- Make sure you read the instructions provided by your domain service before you create an A record.
Besides being free, one of the best parts about hosting your site with GitHub Pages
is that you can use your own domain name.
If you've purchased a domain name for your website, you can configure it so
that it points to your site hosted on GitHub Pages.
So, I'm gonna show you how by configuring the custom domain name I own,
frontendcourses.com, to point to the GitHub Pages server from my site at
That way, when we type the custom domain in the address bar, it will go to GitHub
pages, but the web address we see will always be frontendcourses.com.
When configuring a custom domain name with GitHub pages,
you'll need to follow three simple steps.
First, create a CNAME file containing your custom domain name.
Then point your custom domain's A record to GitHub's DNS, then wait for
the changes to take effect.
So, first, to redirect a custom domain to your GitHub page's site,
you need to create a CNAME file that specifies the custom domain.
So, I'm going to create the CNAME file in the root of my course's directory first,
then commit the file to my GitHub user pages website repository.
When creating the CNAME, you need to name the c name file in all upper case letters.
CNAME stands for canonical name, and it's a type of record used for
creating aliases for domains.
In the CNAME file is where we specify that a domain name is an alias for
So for example, the domain for my website is currently the github domain,
I wanna use my domain name frontendcourses.com as the alias.
So I need to write that domain name in the CNAME file, and
that's all you have to write.
Now the www in the domain is optional in the CNAME, and
it's important to remember that the CNAME can contain only one domain.
Once I push the CNAME to GitHub, it will point the GitHub page's domain,
guilh.github.io to the frontendcourses.com domain.
Back in the terminal, if I run a git status,
it lists the new untracked CNAME file.
So now I'm going to add and commit this file to my local repository by typing git
add period, and git commit -m,
and as the commit messages say add see name.
And finally, I'll push it up to the project's master branch by typing git,
push, origin, master.
So now if I go back to my github repository and
refresh, we can see that the CNAME is now inside the repository.
Although I created a CNAME file and pushed it up to github, the rest of the web
doesn't know that my custom domain name points to this GitHub account.
To do that, I have to update the DNS,
or domain system record, for the frontendcourses.com domain.
I can do that by creating an address record, also called an A record.
An A record is used to point a domain to one or more IP addresses.
So I'm going to create an A record that points to the domain,
frontendcourses.com, to GitHub Pages IP addresses.
You'll usually create an A record through your domain name provider.
Keep in mind that domain name services are different, so make sure you read
the instructions provided by your domain name service before you begin this step.
And I've also posted helpful links about creating A records
in the teacher's notes of this workshop.
I registered my domain name with namecheap.com.
Using namecheap's domain manager I created
two A records that resolve to these two IP addresses.
Now, these are the GitHub IP addresses, which you can find on GitHub's website,
and I've also posted them in the teacher's notes.
Once I create and save the new domain savings,
it will map frontendcourses.com to these IP addresses.
Now, depending on your service,
it can take up to 25 hours for this to take effect, but
it's usually much faster, and often within a few minutes, so, let's take a look.
So, I'll open up a new tab and type frontendcourses.com.
Great. So, now it points to my GitHub pages site.
So, that's it.
My site is now live on the web.
If you want to learn more about DNS, A records, and CNAME,
I've posted links to Treehouse videos on those topics in the teacher's notes.
If you've just set up and hosted your very first website via GitHub pages,
congratulations that's a pretty big deal.
Hey, even I still get excited every time I see a new project I built
go live on the web.
It's a rewarding feeling.
So now that you're site is up on the web for the world to see,
be sure to share your site with the Treehouse community.
You need to sign up for Treehouse in order to download course files.Sign up