Subfolder vs subdomain

What is the best approach? And why?

⭐️ 👀 2023 WEB DEVELOPMENT BOOTCAMP starting in days! Join the waiting list to reserve your spot in my 10-weeks cohort course and learn the fundamentals, HTML, CSS, JS, Tailwind, React, Next.js and much much more! 👀 ⭐️

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: flaviocopes.com/honey.

The second is by using a subdomain, for example honey.flaviocopes.com.

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 flaviocopes.com/honey.

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.

One more thing! ⚠️ ✋

At the end of January I will organize the Web Development Bootcamp.

It's a 10-weeks long cohort online course where I will guide you to becoming a Web Developer.

It's not "just a course". It's a big event I organize once a year.

We'll start from zero, learn the fundamentals of Web Development, HTML CSS, JavaScript, Tailwind, Git, using the command line, VS Code, GitHub, Node.js, we'll then learn React, JSX, how to use PostgreSQL, Astro, Next.js, Prisma, deploying on Netlify/DigitalOcean/Fly/Vercel and much more! 

At the end of the first 10 weeks you'll know how to create web sites and web applications and I'll unlock you the 2nd phase of the Bootcamp: you will get access to a large number of projects exclusive to the Bootcamp graduates, so you can follow my instructions to build things like private areas with authentication, clones of popular sites like Twitter YouTube Reddit, create e-commerce sites, and much much more.

Because once you got the fundamentals, you only learn by working on real, exciting projects.

To find out more, visit bootcamp.dev