Support Forums

Single repo, Single domain, Multiple subdirectories


My website is served as a single git repository. It consists of multiple subdirectories. Each of these subdirectories contain separate build scripts, separate package.json, webpack.config.js, etc.

This is the structure I’m trying to achieve:

  • mywebsite.com
  • mywebsite.com/myproject1
  • mywebsite.com/myproject2
  • mywebsite.com/blog

Is there a standard way to handle such structure? I’ve read about monorepos and redirects, however I cannot put everything together.

I would appreciate any help.

Hey @emma,
There are a few different options for this. This is a nice blog post that outlines one of the more complicated to set up but more elegant and easier to manage ways:

Alternatively, you can go the “easier to set up but less elegant” way :slight_smile: This was is to have a different Netlify site for each of your subdirectories. You would deploy each site from the same repo but set the base in your Netlify site dashboard or netlify.toml file to be the subdirectory you want to build. It would look something like this, assuming your github repo is like github.com/emma/website/project1:


# netlify.toml
// only build homepage
command = "webpack" 

from = "/project1/*"
to = "project-1.netlify.app/:splat"
status = 200
force = true

from = "/project2/*"
to = "project-2.netlify.app/:splat"
status = 200
force = true


  • deploys on project-1.netlify.app from github.com/emma/website repo
  • be sure to deploy to a subdirectory, not the root of the project, as described here
# netlify.toml
base = /myproject1
// build command for myproject1 directory 
command = "webpack" 


  • deploys on project-2.netlify.app from github.com/emma/website repo
  • be sure to deploy to a subdirectory, not the root of the project, as described here
# netlify.toml
base = /myproject2
// build command for myproject2 directory 
command = "webpack" 

… and repeat for /blog. Let us know if that helps or if you have questions along the way!

1 Like

Hi @jen,

Sorry for the late reply.
Thanks a lot for your support!
I chose the second method and it seems to work fine :slight_smile:

I have one more question though.
Since I should set my custom domain only for the main site (if I understand correctly), does this mean that the other subprojects will still be available under their Netlify domains (e.g. project-1.netlify.app)? Is there any way avoid it?

Hey @emma!
Sorry for the delay here. Glad to hear you got your project up and running :raised_hands:

If I understand your question correctly, then yes the subprojects will still be available under their Netlify subdomains, and that’s not change-able, but no one will access them that way- the public way that people will access those projects is via your custom domain.

If you’re not able to access them from your custom domain, or if you’re still seeing the Netlify subdomain in the URL bar when you visit those paths, it sounds like we have more configuration to work out. Please let me know if that’s the case- and share your Netlify URL- so I can take a look :slight_smile:

1 Like

That’s the exact answer I was looking for! Thank you Netlify for your amazing service and personally @jen for your great comprehensive support!

1 Like

Hi @jen !

Thanks for this! I want to have a standalone eleventy blog deployed on a separate netlify site than my main portfolio site. Then, have the blog be at a subdirectory like ivychen-studio.netlify.app/blog. I should be able to just directly set the base in my netlify site dashboard right?

I think this article [Support Guide] Can I deploy multiple repositories in a single site? has what I need. Where do I find the netlify configuration file?

You will have to write that yourself. For instance in the _redirects file of your main site

/blog/*    https://my-blog-site.netlify.app/:splat    200

And in your blog site you will likely want something like

/*    https://my-main-site.netlify.app/blog/:splat     301!
1 Like

thank you! i will try this out ~