DEV Community

Cover image for Do you prefer subdomains or subdirectories?

Posted on


Do you prefer subdomains or subdirectories?

A subdomain is a URL that allows you to essentially create several websites on a single domain. It’s the kind of URL.

Subdirectories, on the other hand, are URLs that host subsets of content in separate “folders.” It’s the kind of URL.

What are your preferred approach to organize website content and rank higher in search results?

Top comments (24)

rzeczuchy profile image

From a user standpoint, I expect a subdirectory ( to follow the same UI as the main site ( A subdomain in my mind will be a separate entity with its own UI.

shelbyspees profile image
shelby spees (she/her) • Edited

This is exactly how I have things set up:

  • Hugo personal site
  • GitBook notes site
  • Notist speaker portfolio

I deploy my Hugo site with Netlify, and I can also manage my subdomains there for these third-party services. Within my personal site I have subdirectory paths like /posts and /about, all built with Hugo and using the same styling.

jacobreidwd profile image
Jacob Reid

I couldn't agree more. I feel subdomains can be useful if you are going for a subproject per se, but if you are working on the same project, website, ect. I'd definitely recommend the use of subdirectories.

vampiire profile image

that’s such a concise way of describing their distinction. thanks for sharing

_garybell profile image
Gary Bell

From a server management perspective, subdomains. It allows much easier separation of code and resources.

From an SEO point, subfolder. Any good points on the main site will help boost the ranking of the blog.

I'm coming at these points from working in a business where the ecommerce is one platform, and the blog is a totally different one on the same tech stack.

qm3ster profile image
Mihail Malo • Edited

subdirectory (path), because:

  • Maintain HTTP2/HTTP3 connection across the wild internet when going from one to the other (even if they all just go to a load balancing router)
  • Less DNS lookups
  • Shared cookies/permissions/localStorage (global darkmode, global signin)
  • Can share cached items, like brand static CSS/imagery/icons, including service worker
  • SEO, different aspects boost each other's relevance

subdomains should only be used when you explicitly need to break one of these, such as:

  • security, having a more locked-down (headers, deployment access, auditing) authentication/payment service
  • directing images/downloads to a third party cdn or service like cloudinary/imgix. (infrastructure simplification is tremendous)
  • ...I can't think of another one at the moment, things like "users of feature x and feature y don't overlap" and "I have a gorillion developers in independent teams working on independent features" has many solutions, from application routers to microfrontends.
  • short urls like<id> and<id> are fun yay (and they usually can be statelessly redirected at edge, let alone have content themselves, so they don't participate in a lot of the drawbacks)
madza profile image

Thanks for the input 🙏❤

exceedteam profile image
Igor T • Edited

Now I use subfolders, before it was subdomains, and I can say that after moving to subfolders my real estate pages starts be better indexing. The effect was not only for that page but for others as well. Hope that helps

yoursunny profile image
Junxiao Shi

My main website uses subdirectory naming. For example, the blog is at .
The reason was that, shared hosting accounts I used initially did not support subdomains.

I tend to use short directory names:

  • /t/: "tech blog", now it's more than tech contents
  • /p/: projects
  • /m/: "me", now it's contact information and social media posts

The structure was designed in 2006, although there has been changes during the 2017 rebuild. Most of the links in past 15 years are still working, thanks to redirects.

Scripts on this website are written in PHP so they can go into subdirectories easily.

When it comes to pages published from GitHub Actions, Node.js or Go servers, etc, it would be difficult to use subdirectories. My new domain arranges contents in subdomains. I'm getting many emails about TLS certificate issuance.

slimdestro profile image

Creating new directories with same content is like wasting storage and putting extra load on wallet however addons and subdomains are good. Just need to add one more table in the database for url prefix

andreidascalu profile image
Andrei Dascalu

It's likely that the primal post misuses the term folder as the question clearly refers to the preferred way of serving content, not the actual server storage model.
Aka: whether you put stuff on subdomain or serve via subpaths from the same fqdn.
Whether you actually have folders or it's just internal routing (as you would have in react or symfony) doesn't seem relevant.

d0x1n profile image
Đorin 💾

good question... I think it depends on your preference.
If it's something out of context for the main domain, let's say missionToMars - I would choose to be a subdomain
Does that make sense ? 😬

raguay profile image
Richard Guay

If it’s the same subject/idea/project/technology stack, only use subdirectories.

If it’s some new idea/project but the same technology stack, subdomains are best.

If it’s a new technology stack totally different than the original, then move to a new domain.

cicirello profile image
Vincent A. Cicirello

I use a combination of the two. My main website has several subdirectories for things like my publications, research, teaching, etc, some of those with their own subdirectories. But then I use subdomains for websites for software projects such as hosting API documentation, such as and . For the part of your question concerning ranking, I'm not sure. I didn't organize it that way for SEO purposes. I did it more for convenience. I suspect that it might not matter as much to SEO as some believe. I base this on Google's search console, which seems to treat everything within the domain as a single entity.

winstonpuckett profile image
Winston Puckett • Edited

For me it depends on if it's a microfrontend architecture. Or if I'm hosting separate projects with one branded url :). My main site could be, where my music might be In short, I use a subdomain when I am routing to a separate "server"

kant312 profile image
Quentin Delcourt

I've had so many problems with subpath in the past that I always end up using subdomains. If we really are talking about separate applications of course. To create these applications we use underlying web systems such as localStorage, sessionStorage or cookies that all expect a specific domain. If you use a subpath, you are sharing data between application and potentially losing bandwidth for transmitting information an application don't care at all. Because of this and server configuration reasons, I tend to avoid subpath if possible.

mjgs profile image
Mark Smith • Edited

I feel that users do not like subdomains.

My impression is that people prefer to read or rather than I could be wrong about this. Maybe subdomains are fashionable again.

Were they ever fashionable? I dunno. Worth mentioning because trends do make a difference.

From the perspective of running a website though, there are considerable advantages to using subdomains. For starters you don’t have all your eggs in one basket, so to speak. One part of your infrastructure can go down, but the rest is still up.

The downside though is that it’s more difficult to manage many different servers rather than one big website with lots of folders.

As your infra grows I feel it’s likely there will be a time when you just have to add something to a subdomain because a particular tech won’t fit into your one big website. The only way at that stage around subdomains is to just have more entirely different domains (i.e. and

The hard part there is to find lots of cool sounding domains at a good price.

mohammad__amin profile image
MohammadAmin Hakim

I prefer the subdomains. it's easiest to remember for users and you can host your blog or service on another server and point it to this subdomain.

sqlrob profile image
Robert Myers

The "host on another server" is independent of subdomains versus subdirectories. A reverse proxy will cover that for you.

yoursunny profile image
Junxiao Shi

Reverse proxy won't work well if two servers are far from each other.

rsa profile image
Ranieri Althoff

If the project will trigger CORS when on a subdomain, subdirectories. For static files, a subdomain with proper caching and no cookies.

victoredier profile image
Victor Edier

Subdomains when possible, it allows separate resources from your main site/app