Netlify has their own docs for Custom Domains, so if you’re looking for horse’s mouth technical docs on this stuff, that should be treated as the source of truth. But I’d like to take a crack at it from a slightly different angle, where we look at where you are and what you wanna do, and the point you in the right direction.
If that’s the case, you can buy it directly through Netlify if you want. There is a big advantage there in that it automatically gets set up to work perfectly, so it’s easier.
You don’t have to buy your domain through Netlify though, you can buy it wherever you like. There is nothing you can’t do with Netlify if you choose to buy a domain elsewhere.
Easiest possible method: register the domain with Netlify.
Alternative: If you anticipate some hosting/DNS churn, like you think you might ultimately need to host elsewhere, it probably makes more sense to manage to domain somewhere agnostic where you can re-point DNS stuff wherever you need to. It’s not that you can’t manage the DNS on Netlify and point it elsewhere, it just doesn’t make loads of sense. Also, there is something to be said (lower cognitive load) managing all your domains in one place if you can.
No problem. The rest of this article deals with that scenario.
If you are, this is the best way. It means you don’t have to fiddle with subdomains and the CDN features work the best. The requires you to go into the DNS administration area of wherever you bought the domain and change the nameservers there. Every domain registrant will be a bit different in where and how you do that.
I would guess that the main reason you might have this preference is that you use Cloudflare, or perhaps something else similar that gives you fancy performance and security advantages by going through their proxy. Netlify actually says that you don’t need Cloudflare with them, because many of the main advantages of Cloudflare Netlify already provides.
Technology is a moving place though, and it’s entirely possible that you need or really want some feature that a proxy service like Cloudflare provides.
If you need to do this, you’ve got two options:
- Use the www. version of your domain and a CNAME record to point to Netlify (you can “CNAME flatten” it to remove www. if you really want).
- Point the A record to Netlify’s load balancer IP address. I’d list it here, but you’re better off getting it from their docs in case it changes.
This is actually a lot easier. If this is the case, you probably already own the domain name anyway, and you should stick with your existing DNS host. All you need to do is CNAME the subdomain to the Netlify domain. Here’s an example where the root domain is hosted elsewhere and uses Cloudflare for DNS, but the subdomain is Netlify hosted and points with a CNAME.
If you care about the Netlify domain sitting there with the same content on it, you can always redirect it. Also, you might need to “gray cloud” (turn off the Cloudflare proxy) for those subdomains so Netlify can issue SSL certificates for it.