Putting your own domain on a free static host is a ten-minute job that most people spend an afternoon on. The records themselves are short. What goes wrong is the order of the steps, and a rule about domains that nobody mentions until you trip over it.
This guide gives the records for the three most popular free hosts, and explains the rule.
The rule: a domain itself is not like a subdomain
There are two kinds of address you might want to use.
- The domain itself, such as
example.com. You will also see it called the apex or root domain. - A subdomain, such as
www.example.comorblog.example.com.
DNS treats them differently. A subdomain can have a CNAME record, which says “this name is another name for that one”. It is the easy case: you point www at your host’s address and the host looks after the rest.
The domain itself can’t have an ordinary CNAME, because it already has to hold other records, and a CNAME isn’t allowed to share a name with anything else. So for the domain itself you need A records, which give numeric addresses directly, or a special record type that some DNS providers offer to get round the rule (called ALIAS, ANAME, or CNAME flattening, depending on who you ask).
That is the whole reason the instructions for example.com are longer than the ones for www.example.com.
In the tables below, a name of @ means the domain itself.
GitHub Pages
For the domain itself, add four A records, and four AAAA records for IPv6:
| Type | Name | Value |
|---|---|---|
| A | @ | 185.199.108.153 |
| A | @ | 185.199.109.153 |
| A | @ | 185.199.110.153 |
| A | @ | 185.199.111.153 |
| AAAA | @ | 2606:50c0:8000::153 |
| AAAA | @ | 2606:50c0:8001::153 |
| AAAA | @ | 2606:50c0:8002::153 |
| AAAA | @ | 2606:50c0:8003::153 |
For www, or any other subdomain:
| Type | Name | Value |
|---|---|---|
| CNAME | www | <username>.github.io |
The CNAME points at your GitHub user or organisation address. It never includes the repository’s name, which is the most common mistake here.
Then, in the repository, open Settings → Pages, enter the domain as the custom domain, and tick Enforce HTTPS once it becomes available. GitHub requests the certificate for you after it has seen the DNS records, and says that can take up to a day.
Netlify
Add the domain to your site in Netlify first, under its domain settings. Then, at your DNS provider:
| Type | Name | Value |
|---|---|---|
| A | @ | 75.2.60.5 |
| CNAME | www | <your-site>.netlify.app |
If your DNS provider offers ALIAS, ANAME or flattened CNAME records for the domain itself, Netlify’s documentation prefers one of those, pointing at apex-loadbalancer.netlify.com, and treats the A record as the fallback. Either works.
Netlify issues the HTTPS certificate itself once the records are in place.
Cloudflare Pages
Cloudflare is stricter about order, and about where your DNS lives.
For a subdomain, first add it in the Pages project under Custom domains. Then add the record:
| Type | Name | Value |
|---|---|---|
| CNAME | www | <project>.pages.dev |
Do it in that order. If you add the record without telling the Pages project about the domain, visitors get an error instead of your site.
For the domain itself, the domain’s DNS has to be managed by Cloudflare. That means moving its nameservers to Cloudflare, which is free. Once it is there, adding the domain under Custom domains creates the record for you.
The order that avoids trouble
- Add the domain at the host first, where the host asks for that.
- Add the DNS records.
- Wait. See below.
- Check HTTPS works, then set your site’s own address to the new domain so its feeds and links use it.
Why it doesn’t work straight away
DNS answers are cached all over the internet, each for as long as the record’s time to live allows. A new record can be visible in minutes, or it can take most of a day to reach everyone. Changing a domain’s nameservers takes longer than changing a record.
That means a check that fails five minutes after you add a record tells you nothing. The same check an hour later might pass.
How to check
On a Mac or Linux, in a terminal:
dig +short example.com
dig +short www.example.com
The first should print your host’s addresses. The second should print the host name you pointed at, then its addresses.
Without a terminal, any “DNS lookup” website will show you the same thing. Be aware that those sites are one more party being told which domain you are setting up.
www or no www
Pick one to be the real address and let the other lead to it. Hosts differ in how much of that they do for you, so look for a “primary domain” or redirect setting where you added the domain. What matters is that your site’s own settings, its feeds and its sitemap all name the one you chose.
Where Selfish fits
Selfish is a native app for iPhone, iPad and Mac that builds a static site and publishes it to GitHub Pages, Netlify or Cloudflare Pages, among others.
When a site’s address is your own domain, its Publishing settings show the exact records above for the host you use, with your own names filled in, and the steps in the right order. A Check button then looks the domain up and tells you plainly whether it points at your host, points somewhere else for now, or doesn’t lead anywhere yet.
The check uses your device’s own resolver, so your domain isn’t sent to a lookup service. On GitHub Pages, Selfish also keeps the CNAME file that holds your domain setting, so a publish never resets it.
It is on the App Store as a one-time purchase, at a £3.99 introductory price, rising to £9.99 in December. The custom domains docs show the same records in the app’s own words.