Custom domain
After the first deploy you’ll have a host-generated URL like my-site.pages.dev, my-site.vercel.app, or my-site.netlify.app. Pointing your real domain at it is two changes — one on the host, one at your DNS provider.
Step 1 — Update Astro
Section titled “Step 1 — Update Astro”In astro.config.mjs, set the production site:
export default defineConfig({ site: 'https://yourdomain.com', // …});And in src/config/site.ts:
url: "https://yourdomain.com", // no trailing slashThese two values feed canonical URLs, the sitemap, OG tags, and any place the build needs to generate absolute URLs. Get them right before you submit your site to Google Search Console — incorrect canonicals are a pain to walk back.
Redeploy after changing.
Step 2 — Add the domain on your host
Section titled “Step 2 — Add the domain on your host”Pick the section that matches your host:
Cloudflare Pages
Section titled “Cloudflare Pages”- Project → Custom domains → Set up a custom domain.
- Enter
yourdomain.com. - Cloudflare auto-detects whether your domain is on Cloudflare DNS:
- On Cloudflare DNS: it sets the CNAME automatically. Done.
- Elsewhere: Cloudflare gives you a CNAME target like
my-site.pages.dev. Add a CNAME at your DNS provider — see Step 3.
- Add
www.yourdomain.comtoo (separately) so both work.
Vercel
Section titled “Vercel”- Project → Settings → Domains → Add.
- Enter
yourdomain.com. - Vercel asks: which version should be the canonical?
- Apex (
yourdomain.com) — A record points to Vercel’s IPs. - Subdomain (
www.yourdomain.com) — CNAME tocname.vercel-dns.com.
- Apex (
- Add the other variant too (with a 301 redirect to the canonical).
Netlify
Section titled “Netlify”- Site → Domain management → Add custom domain.
- Enter
yourdomain.com. - Netlify gives you either an ALIAS/ANAME record (for the apex) or a CNAME (for subdomains).
- Add both
yourdomain.comandwww.yourdomain.com; configure the redirect in Domain management → HTTPS settings.
Step 3 — Configure DNS
Section titled “Step 3 — Configure DNS”Where your DNS lives depends on where you bought the domain. Common providers:
- Cloudflare — dash.cloudflare.com → your domain → DNS.
- Namecheap — Domain List → Manage → Advanced DNS.
- Google Domains / Squarespace — DNS → Custom records.
- Porkbun — Manage → DNS records.
For most setups, you’ll add:
Apex (yourdomain.com)
Section titled “Apex (yourdomain.com)”| Type | Name | Value |
|---|---|---|
| A | @ | (Vercel/Netlify will give you specific IPs) |
| ALIAS | @ | my-site.pages.dev (Cloudflare/Netlify supported; not all providers) |
If your DNS provider supports ALIAS/ANAME, prefer that — it’s more flexible than A records.
Subdomain (www.yourdomain.com)
Section titled “Subdomain (www.yourdomain.com)”| Type | Name | Value |
|---|---|---|
| CNAME | www | my-site.pages.dev |
After saving, DNS propagation takes anywhere from 30 seconds to 24 hours. Most major providers update within 5 minutes.
Step 4 — Verify
Section titled “Step 4 — Verify”dig yourdomain.comdig www.yourdomain.com
# Or in a browser:curl -I https://yourdomain.comLook for a 200 and a header like cf-ray: (Cloudflare) or x-vercel-id: (Vercel) — that confirms requests are hitting your host.
SSL / HTTPS
Section titled “SSL / HTTPS”Every host listed above issues a Let’s Encrypt certificate automatically. After DNS resolves, the cert lands within a few minutes. You don’t have to do anything.
If you see a “this site is not secure” warning after DNS resolves, wait 10 minutes. If it persists past 30 minutes:
- Cloudflare: check that SSL/TLS mode is set to Full (not Flexible).
- Vercel / Netlify: re-add the domain on the dashboard — that triggers a cert refresh.
www vs apex — which is canonical?
Section titled “www vs apex — which is canonical?”Pick one. The other should 301-redirect to it.
- www.yourdomain.com is canonical historically — easier with CNAMEs and works on every DNS provider.
- yourdomain.com (apex) is shorter and “modern” — requires ALIAS/ANAME or A records.
Both are fine. Just don’t run them as two separate sites — that splits Google’s PageRank.
Common gotchas
Section titled “Common gotchas”What’s next
Section titled “What’s next”- Cloudflare Pages — full setup if you started from scratch.
- Configure → SEO — set OG tags using the new canonical.