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.

Practical differences between the two structures
TopicSubdirectory: example.com/blogSubdomain: blog.example.com
HostingSame server or a proxy ruleCan point anywhere with a DNS record
robots.txtOne file covers itNeeds its own file
CookiesShared by defaultShared only if Domain is set on the cookie
AnalyticsSame setupGoogle recommends cross-domain setup
Search ConsoleCovered by the main propertyCovered by a Domain property, or add its own
Google's international guideLow maintenance, single server locationEasy 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

  1. Does this section run on a hosted tool that only offers a subdomain (many shop and help-desk tools)? No
  2. Must it live on a different server or in a different country from your main site? No
  3. Is it run by a separate team with its own login and releases? No
  4. 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

  1. List the sections you want to add: blog, store, help centre or other languages.
  2. Check whether each one runs on the same platform as your main site.
  3. Answer the decision helper for each section.
  4. If you move an existing section between the two, redirect every old address to its new one.

Tips

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.

Start for free or see all free tools. We.Inc is free to start, with no card needed. AI building is on paid plans from $20 a month.

More in Guides

We.Inc is an AI-powered website builder you can resell under your own brand. Launch a branded client dashboard, bill on Stripe Connect, and deliver AI-generated websites in minutes. White-label plans start at $99 a month for 25 client sites, with a 7-day free trial and no per-site fees.

Product

Who It's For

Features

Resources

Company

View Sitemap