In 2026 the www vs root-domain debate is almost entirely cosmetic — until you accidentally serve the same content on both, and now Google sees two sites with one URL of authority each. The decision is small. The execution must be precise — DNS, hosting, canonical tag, and Search Console all aligned.
Background
Historically www was a hostname convention pointing to the web server, while the root domain might point at email, FTP, or other services. Modern hosting collapses this — both can point at the same web service. What matters is picking one as canonical and making the other 301-redirect to it, so search engines, browsers, and copy-paste users converge.
How to tell
- Both
https://yoursite.comandhttps://www.yoursite.comload your site (no redirect between them). - Search Console shows two properties or split impressions for the same content.
- Backlinks point at a mix of both versions.
- You see canonical tag on one version pointing at the other.
dig +shortreturns IPs for both apex andwwwindependently.
Quick verdict
Pick one — most modern indie sites pick the root (yoursite.com) because it is shorter and matches typing habits. Set up a 301 redirect from the other to the chosen one. Configure DNS, host, and canonical tags to all agree.
Before you start
- Lower DNS TTL to 300s 24 hours before the change.
- Choose canonical (apex or
www) — write it down. - Know who runs your DNS (registrar vs Cloudflare).
Step by step
-
Decide and write it down. Default to apex for new indie sites. Stay with
wwwif you already have an establishedwwwsite with backlinks. -
Add DNS records — both, ultimately resolving to the same place. Apex-primary on a typical host:
Type Name Value TTL
A @ 76.76.21.21 (host's anycast) 300
A @ 76.76.21.22 300
CNAME www cname.vercel-dns.com. 300
Firebase-style:
Type Name Value TTL
A @ 199.36.158.100 300
A @ 199.36.158.101 300
CNAME www your-project.web.app. 300
-
In your host, mark one as primary. Vercel: Project → Domains → mark
yoursite.comas Primary,www.yoursite.comis auto-redirected with 301. Firebase: Hosting → Custom domains → set redirect direction. -
If your host does not auto-redirect (Cloudflare-fronted only), add a Page Rule or Redirect Rule:
# Cloudflare Bulk Redirects (CSV import)
source_url,target_url,status,preserve_query_string,preserve_path_suffix
https://www.yoursite.com/*,https://yoursite.com/$1,301,true,true
Or in Cloudflare’s Redirect Rules UI:
When incoming requests match
Hostname equals www.yoursite.com
Then
Type: Static
URL redirect: https://yoursite.com${uri.path}${uri.query}
Status code: 301
Preserve query string: ON
- Set canonical tag on every page pointing at the chosen version. In an Astro layout:
<link rel="canonical" href={`https://yoursite.com${Astro.url.pathname}`} />
Verify after deploy:
grep -R 'rel="canonical"' dist | grep -v 'https://yoursite.com' | head
# any output is a leak to the non-canonical version
-
In Search Console, add the chosen version as the property. Use Domain property (TXT) so both apex and
wwware covered, then make sure the URLs you submit in the sitemap are the canonical apex. -
Verify the redirect with
curl:
curl -sI https://www.yoursite.com | head -3
# HTTP/2 301
# location: https://yoursite.com/
curl -sI http://yoursite.com | head -3
# HTTP/1.1 301 Moved Permanently
# Location: https://yoursite.com/
curl -sI https://yoursite.com | head -3
# HTTP/2 200
The chain you want is at most one hop: http://www → https://apex should not pass through http://apex or https://www. Single-hop is the goal.
- Update controllable backlinks (social bios, GitHub README, email signatures). 301s handle search-engine-visible inbound links; humans see the redirect blink.
Implementation checklist
- DNS has records for both apex and
www, ultimately to the same host. - Host’s “primary domain” matches your chosen canonical.
curl -sIshows 301 from non-canonical to canonical in one hop.- Canonical tag on every page references the chosen version.
- Search Console Domain property + sitemap uses the canonical.
After-launch verification
dig +short A yoursite.comanddig +short A www.yoursite.comboth resolve.- Lighthouse on both URLs — one gets 200, the other shows the redirect.
- Search Console Performance page shows traffic only on the canonical version after 4 weeks.
Common pitfalls
- Serving the same content on both root and
wwwwithout a redirect — duplicate content in Google’s eyes. - Pointing root and
wwwat different builds (one to staging, one to prod) — common when a redirect is misconfigured. - Choosing
wwwthen forgetting half your DNS provider docs assume root — leads to broken records. - Mismatched canonical tag — page is on root but tag says
www, or vice versa. Inconsistency confuses crawlers. - Submitting one version to Search Console and using the other for canonical — pick one and use it everywhere.
- A multi-hop redirect (
http://www→http://apex→https://apex) that loses signal. Always one hop.
FAQ
- Does Google care which one I pick?: No, as long as you pick one and 301 the other. Mixed signals are what hurts.
- Is
wwwoutdated?: Stylistically, yes — most new sites drop it. Technically it is still completely fine and even has slight DNS flexibility advantages (CNAME at subdomain is universally supported). - Can I change later?: Yes, but treat it like a mini-domain migration — set up 301s, update Search Console, update canonical. Expect a small SEO blip during recovery.
- What if my host only supports one?: Most modern hosts support both with auto-redirect. If yours does not, switch hosts or front it with Cloudflare to handle the redirect.
- Should I CNAME the apex via Cloudflare CNAME flattening?: Yes, that is the standard way to use CNAME-like behavior on the apex when your host wants a CNAME but the registrar will not accept one at
@.
Related
- DNS A vs CNAME Explained
- Subdomain vs Subdirectory
- Will Changing Domains Hurt SEO
- Firebase custom domain
- Vercel custom domain
Tags: #Indie dev #Domain #DNS #Canonical #SEO