← All posts

Adding custom domain for Netlify website

· Netlify, Jamstack

First appeared on Stackrole · Updated

Let's add a custom domain to your Netlify-hosted website. Netlify has reorganised its dashboard since I first wrote this on Stackrole in 2020, so these steps follow the current layout.

Add the domain

  1. Open your site in the Netlify dashboard.
  2. In the sidebar, open Domain management.
  3. Choose Add a domain, then Add a domain you already own. (You can also buy one from Netlify here.)
  4. Enter your domain, select Verify, and confirm with Add domain.

The first domain you add becomes the primary domain for the site. Netlify adds both example.com and www.example.com and redirects one to the other.

Point the DNS at Netlify

You have two options. Pick one.

Option 1: Netlify DNS (easiest)

Netlify manages the DNS for you, including the HTTPS certificate and the www redirect.

  1. Choose Set up Netlify DNS for your domain.
  2. Add any existing DNS records you need to keep, for example MX records for email. Skipping this can stop your email working.
  3. Netlify shows you four name servers. At your domain registrar, open the domain's DNS or name server settings and replace the existing name servers with Netlify's.

Option 2: keep your current DNS provider

Leave the name servers alone and add records at your DNS provider instead. Netlify shows the exact values under Pending DNS verification next to your domain:

  • For www: a CNAME record pointing to your site's yoursite.netlify.app address.
  • For the bare domain: an ALIAS, ANAME or flattened CNAME record if your provider supports it, otherwise the A record Netlify gives you.

Wait, then check HTTPS

DNS changes can take up to 48 hours to spread, though it is usually much faster. Once Netlify sees the domain, it issues a free Let's Encrypt certificate automatically. You can check its status under Domain management → HTTPS.

Stuck on the registrar side? Search for "how to change name servers on [your registrar]". Every registrar's screens are a little different.

For anything not covered here, Netlify's domains documentation is thorough.