Subdomain vs Subdirectory: Which to Use
A subdirectory (example.com/blog) keeps everything on one host, so it shares one server, one robots.txt and one analytics setup with your main site. A subdomain (blog.example.com) is a separate host: easier to run on different software or servers, but each part needs its own setup. When nothing forces a split, the subdirectory is simpler.
| Topic | Subdirectory: example.com/blog | Subdomain: blog.example.com |
|---|---|---|
| Hosting | Same server or a proxy rule | Can point anywhere with a DNS record |
| robots.txt | One file covers it | Needs its own file |
| Cookies | Shared by default | Shared only if Domain is set on the cookie |
| Analytics | Same setup | Google recommends cross-domain setup |
| Search Console | Covered by the main property | Covered by a Domain property, or add its own |
| Google's international guide | Low maintenance, single server location | Easy setup, allows different server locations |
Updated
A subdomain is the part before your main domain name, like shop in shop.example.com. A subdirectory, also called a subfolder, is a path after it, like /shop. Both can rank, and the right pick usually depends on how your site is built and hosted. Answer the questions below for a suggestion with the reasons.
Decision helper
- Does this section run on a hosted tool that only offers a subdomain (many shop and help-desk tools)? No
- Must it live on a different server or in a different country from your main site? No
- Is it run by a separate team with its own login and releases? No
- Do you want one robots.txt, one analytics setup and shared cookies with no extra work? Yes
Suggestion
Use a subdirectory, such as example.com/blog. Nothing you said requires a separate host.
Runs in your browser. Your answers are not saved or sent.
Setup snippets
A subdomain needs a DNS record; a subdirectory on another system needs a proxy rule on the main server.
DNS record for a hosted shop on a subdomain
Your shop provider tells you the exact target. This CNAME points shop.example.com at it.
shop.example.com. 3600 IN CNAME stores.provider.example.Serve a separate blog under /blog with Nginx
The main server fetches /blog pages from the blog's own host and serves them under your domain.
location /blog/ {
proxy_pass https://blog-backend.example.net/;
proxy_set_header Host blog-backend.example.net;
}Share a cookie with every subdomain
With Domain set, the cookie is sent to example.com and to shop.example.com.
Set-Cookie: cart=abc123; Domain=example.com; Path=/; Secure; HttpOnly
What actually changes between the two
To a browser and a crawler, blog.example.com is a different host from www.example.com. Google's robots.txt guide says a file only applies to the protocol, host and port where it is posted, so each subdomain needs its own. The Google Analytics help on cross-domain measurement recommends that setup for subdomains, because visits that cross cookie domains can show up as self-referrals.
A subdirectory avoids all of that, but it needs your main site to serve the path. If the blog runs on different software, that usually means a reverse proxy, a server rule that fetches pages from another system and serves them under your domain.
Moving between the two later
Moving from blog.example.com to example.com/blog is a site move for that section. Google's site move guide says to keep redirects generally at least one year, and its Change of Address tool is only for moves from one domain or subdomain to another.
Plan the redirect map before you switch: every old post address points to the matching new one.
How it works
- List the sections you want to add: blog, store, help centre or other languages.
- Check whether each one runs on the same platform as your main site.
- Answer the decision helper for each section.
- If you move an existing section between the two, redirect every old address to its new one.
Tips
- Hosted shop and help-desk tools often only offer a subdomain. That is a fine reason to use one.
- If you choose a subdomain, add it to your sitemap plan and give it a robots.txt of its own.
- Link between the main site and the subdomain in menus and footers so visitors and crawlers move freely between them.
- Do not switch structure for SEO alone on a site that already ranks. Moves cost time while search engines process the redirects.
Frequently asked questions
Does Google prefer subdirectories over subdomains?
Google's guide for multi-regional sites lists both as valid structures and describes trade-offs in setup and maintenance, not a ranking rule. We found no Google documentation that ranks one above the other.
Should my blog be on a subdomain?
Only if the blog has to run on a different platform or server that cannot sit behind your main domain's path. Otherwise example.com/blog keeps one robots.txt, one analytics stream and one place to manage.
Which is better for other languages?
Google's international guide lists country domains, subdomains and subdirectories. Subdirectories such as /de/ are easy to set up and low maintenance; subdomains allow different server locations. Either way, connect the versions with hreflang tags.
Do cookies work across a subdomain?
MDN explains that a cookie set without a Domain attribute stays on the host that set it, not its subdomains. Set Domain=example.com when a login or cart must carry over from the main site to shop.example.com.
Do I need a new Search Console property for a subdomain?
Not if you verified a Domain property. Google's help says a Domain property includes data for all protocol and subdomain variations. A URL-prefix property for https://www.example.com does not include the blog subdomain.
Related: Domain vs hosting, www vs non-www, hreflang tags, Domain forwarding: 301 vs 302, Google Search Console guide.
Build your site free or see all free tools. On We.Inc you can build your site free, with no card and no trial needed to start. AI building is on paid plans from $19 a month.
More in Guides
- Supabase Alternatives: Which Backend Fits Your Project?
- Supabase Authentication With supabase-js v2
- Supabase CLI: Install It and Learn the Commands You Will Use
- Supabase MCP Server: Connect Safely in Five Minutes
- Supabase Pricing: What Each Plan Costs in October 2026
- Supabase vs Firebase for Web Apps
- Svelte 5 Runes, Side by Side with Svelte 4
- Svelte vs React: One Component, Two Ways
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App