Guides

Subdomains vs Subfolders: How to Structure Your Website

Should your blog or shop live at blog.example.com or example.com/blog? Compare setup, SEO, SSL, cookies and email to choose the structure that fits.

By Zebra Hosting Cloud

Sooner or later a growing website needs a new section: a blog, a shop, a help centre, a members' area. You then face a choice. You can put it in a subfolder, such as example.com/blog, or on a subdomain, such as blog.example.com. Both work, but they behave differently in DNS, hosting, analytics and search. This article helps you decide.

The difference in one minute

  • A subfolder (or subdirectory) is a path on the same site. It lives on the same server and under the same domain name, so the whole thing is one website.
  • A subdomain is a separate hostname under your domain. It has its own DNS record, so it can point to a completely different server or service.

When a subfolder is the better choice

  • Content that belongs to the main site, such as a blog that supports your products. Everything stays within one site, which keeps analytics, navigation and branding simple.
  • Search visibility. Search engines can crawl and rank both structures, and they have said that either can work. Many site owners still prefer a subfolder for content that should build the main site's authority, because it avoids the question of whether a subdomain is judged as part of the main site. Treat this as a practical preference, not a guaranteed rule.
  • Simplicity. One site, one certificate, one set of settings, one place to look when something breaks.

When a subdomain is the better choice

  • A different platform. Your main site is a WordPress site, but the shop runs on a hosted shop platform or the help centre is a separate product. A subdomain lets you point that hostname elsewhere with a single DNS record.
  • A different server or technology. A web application, an API, a staging copy or a customer portal often runs on a separate stack.
  • Separation for security. Isolating a risky or experimental section limits the effect of a problem. Cookies can also be scoped by hostname.
  • Different teams or regions. Each can manage its own part independently.
  • Staging and testing. staging.example.com is a safe place to test changes.

Comparison

AspectSubfolderSubdomain
DNSNo new recordNew A or CNAME record
ServerSame siteCan be anywhere
SSL certificateCovered by the main certificateNeeds coverage: its own certificate or a wildcard
AnalyticsSingle property, simpleMay need cross-domain setup
Cookies and loginsShared automaticallyShared only if scoped to the parent domain
Email reputationNot relevantUseful to separate mail streams
MaintenanceOne systemOne per subdomain

Practical details

SSL certificates

Every hostname you serve over HTTPS must be covered by a certificate. A certificate for the main domain does not automatically cover shop.example.com. You can get a separate free certificate for each subdomain, or use a wildcard certificate if your setup allows it. Subfolders need nothing extra.

Cookies, logins and tracking

If users log in on the main site and need to stay logged in on a subdomain, cookies must be set for the parent domain, which has security implications. Analytics also need configuration to treat a subdomain as the same site. Plan this before you launch, not after the first data gaps appear.

Email

Subdomains are useful for email. Sending newsletters or website mail from a subdomain keeps its reputation separate from your main domain, and each subdomain can have its own SPF and DKIM records.

Moving later

Changing structure later means redirects for every URL, careful testing, and a period when search rankings can fluctuate. It is best to choose with some care at the start. If you must move, use permanent redirects from each old address to its new equivalent, and update internal links, sitemaps and analytics.

A short decision guide

  1. Is the new section the same platform as your main site, and is it content that supports it? Use a subfolder.
  2. Is it a separate application or hosted by a different provider? Use a subdomain.
  3. Is it a test or staging copy? Use a subdomain and block it from search engines.
  4. Unsure? Start with a subfolder, since it is simpler.

Common mistakes

  • Leaving a staging subdomain open to search engines, producing duplicate content.
  • Forgetting the certificate for a new subdomain, so visitors get a warning.
  • Creating a wildcard DNS record that makes every random subdomain resolve to your site.
  • Putting a CNAME on a name that also needs email records.

Sitemaps, robots and monitoring

Each subdomain is treated as its own host for several purposes. It has its own robots rules and usually needs its own entry in search engine webmaster tools and its own sitemap. Subfolders share the settings of the main site. Remember this when you set up monitoring and uptime checks: a problem on the shop subdomain will not show up if you only watch the main address. Add each hostname to your checks so that you notice when one part of the site breaks.

Structure and hosting with Zebra Hosting

Subdomains can be added in Plesk, and free Let's Encrypt SSL certificates are available on Zebra Hosting plans, so securing a new section takes little effort. Support in 17 languages can help you decide on the structure for your site. See shared hosting or the SSL page.