CodeBlanks Logo Icon CodeBlanks

Custom domain

Learn to bind a custom domain.

What is a custom domain?

A custom domain means the site is published under your own domain name. To link a domain like www.ornek.com to the site you set up DNS records and tell GitHub about it. This notice is given with a CNAME file.

echo "www.ornek.com" > CNAME

The CNAME file

The CNAME file contains the custom domain where the site will be published. This file sits in the root folder of the publish branch. The DNS pointing must also connect the domain to GitHub servers.

cat CNAME
www.ornek.com

The file content contains only the domain name.

Practice Create the CNAME file

Create index.html and save it quietly. Then create a CNAME file containing the domain www.ornek.com, add it and save quietly. Print the contents of the CNAME file.

Starter code

terminal
git init -q
# 1) index.html olustur, ekle ve sessizce kaydet
# 2) www.ornek.com alan adini CNAME dosyasina yaz
# 3) CNAME dosyasini ekle ve sessizce kaydet
# 4) CNAME icerigini yazdir

Sample solution

terminal
git init -q
echo "site" > index.html
git add index.html
git commit -q -m "ilk"
echo "www.ornek.com" > CNAME
git add CNAME
git commit -q -m "domain"
cat CNAME

Expected output

www.ornek.com

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which file is used to link a custom domain?

  • The .gitignore file
  • The Makefile
  • The LICENSE file
  • The CNAME file Correct answer

Explanation: The custom domain is declared with the CNAME file; the file sits in the root folder of the publish branch.

2 Write the domain

Question
echo "www.ornek.com" > ____
Answer
echo "www.ornek.com" > CNAME

Explanation: The custom domain is written in the CNAME file; this file sits in the root folder of the publish branch.

3 Custom domain

Term Meaning
custom_domain Publishing with your own domain
DNS Points the domain to a server
CNAME The file that declares the domain
domain_name The internet address of the site

All lessons in Advanced