I got involved in a discussion about using subdomains vs subfolders.
Say I want to create a new section on my website, dedicated to selling honey.
I don’t produce nor sell honey, it’s just an example. Although one of my friends has bees and produces his own honey and it’s delicious 😋
The honey part of the website would be pretty big, with its own application to manage the e-commerce.
I could add this on my website in two ways. The first is by using a subfolder, like this:
The second is by using a subdomain, for example
There is a third option, which is using its own domain name, like
flaviohoney.com. But let’s focusing on keeping our original domain.
A subdomain makes things easier to manage: you have your own completely separate app or CMS or anything, you store it separately in its Git repository if that’s what you use for CI/CD, and you can also host it separately on its own hosting.
I think it’s the ideal solution when you are using an external service like Shopify or anything, as they let you use a subdomain.
A subfolder on the other hand is a bit more complicated because unless you come up with creative ways on the server side (which implies you need to manage your own server), the code must all be put under the original code that manages the main domain.
There is a huge advantage, however, that moves the bar toward the subfolder approach: SEO.
Google does not officially confirm it, but it considers subdomains as completely different sites from the main domain.
honey.flaviocopes.com would not inherit the SEO “juice” that
flaviocopes.com might have. Having many subdomains will dilute the domain authority over multiple subdomains rather than centralizing it in the main domain.
This reason alone could justify using
From the branding standpoint, I don’t personally think there are differences. It’s much better to have a separate domain, logo and design for a big project. But if it’s just an idea or something you want to test-drive for example, without investing time and effort into having a separate domain, then both subfolder or subdomain approaches will work fine.
Want to become a better Web Developer? Join the 2022 Web Development Bootcamp!