[Support Guide] Can I deploy multiple repositories in a single site?

Last reviewed by Netlify Support: Dec 2021

Say you have an awesome blog as part of your larger website. But you’ve chosen to have your awesome blog in its own, separate git repository apart from the rest of your site content. How can you make this work so that your visitors have a seamless experience browsing that content as well under your one, main hostname? Proxying to the rescue!

Yes, Netlify is built around the “single codebase per site” model. But this isn’t to say that you can’t host multiple repositories under a single hostname! The choice is completely yours.

I’ll describe a typical workflow for how to do this. In this example, both sites are hosted on Netlify. However, this workflow should work equally well even if the second site is not hosted on Netlify.

Let’s connect your blog with its own repository to your existing marketing site that has a totally separate code base and lives in its own repository . Your blog will live on the Marketing site (already configured as www.yoursite.com) as Blog - YourSite.com in this example.

  1. Blog content should be published on its own site, but with a special caveat. You’ll want to deploy the blog as a subdirectory of the published site (that is: not in the root directory). Since you’ll browse it on Blog - YourSite.com as just /blog/index.html, you’ll want to publish it under /blog/ (not just /index.html).
    So, for example, /assets/logo.png becomes /blog/assets/logo.png. References to assets should look like <img src=/blog/assets/logo.png>, without a leading hostname. You can also reference assets from the main site in this codebase as <img src=https://www.yoursite.com/assets/header.png>
    Another way to accomplish this is to make sure that all of your content has relative paths for all links within the subsite, only, like this: <img src=filename-with-no-path-and-not-starting-withslash.png>

  2. On your Marketing site, you’ll deploy the main site’s code as usual, but you’ll add some special configuration to refer to the other site using a proxy redirect. For example:
    /blog/* https://yourblogsite.netlify.app/blog/:splat 200!

  3. Test the blog site (recalling that you’ll browse the directory /blog/* rather than the default /)! First you should make sure you can see your blog and that all assets load appropriately. Check those assets you have embedded in the blog site as well as those referenced from the main site.

  4. Test via the redirect! Visit Blog - YourSite.com and make sure that things look as expected. Assets should still load, but you’re now connecting to the Marketing site, and Netlify is reverse proxying to your second site secretly and quickly - and sending the responses back via that connection to www.yoursite.com.

How are things looking? Let us know in the comments below!

Is it possible to deploy multiple repositories to the same domain?
Error proxying to deploy multiple repos in single site
Bug in non-trailing slash rewrite
Unable to proxy a blog from a different gitlab repo (to the same custom domain)
Rewrite not working as expected
Deploying to subdirectory
Deploy multiple netlify apps to single domain and subfolders?
301 redirect to a proxy 200 redirect
Need help with rewrite via _reredirects file for https://coronatimemap.netlify.app
Hosting a Next.js website and a Hexo blog on the same domain
Adding a project to my main site (2 GitHub repos)
Can I build two different sites from subdirectories in the same repo?
Portfolio site with subtrees
Point one domain to 2 separate hosts
Forwarding subdirectory under a main site to a subdomain
Root folder redirect and subfolder shadow
6:11:00 PM: System Error
Proxy redirect to another WordPress site
Proxy redirect to another WordPress site
SEO is not working after 200! redirect implemented
Migrating access for subdirectory-based wordpress sites to Netlify
Hosting two sites at one URL - status codes - monorepo
Publish Hugo blog to subdirectory
Any downsides to multiple proxies?
RangeError: Maximum call stack size exceeded
Proxy redirect shows blank page
Two codebases to build a single site
I have already a static website in CSS and HTML, and I want to transform it into dynamic website how can I place my dynamic app to the last page of the website?
Multiple React Deployments in subdomains?
How can I host multiple sites from one repository?
Could I deploy multiple branches in subpath of the same domain?
I need advice for large site setup
I18N with multiple content folders
Need help doing a redirect/rewrite
Versioned netlify deploys
Need help doing a redirect/rewrite
Different instance for different path
How to configure react app with a router and docusaurus app on the /docs path
Simple question about redirects
SubDomain redirect - How do you remove slug?
How to add same domain to other sites/projects?
Netlify Functions speed
"Another site is already using this domain" error; cannot delete old site or old domain to rectify
Deploying Multiple Repositories To a Single Site -- Potentially Missing Something Simple
Deploying Multiple Repositories To a Single Site -- Potentially Missing Something Simple
How to redirect?
Deploying Multiple React apps to one domain
Setting up ghost blog /blog with Netlify site
How does redirect caching work?
Single repo, Single domain, Multiple subdirectories
Single repo, Single domain, Multiple subdirectories
Shared Assets in a Monorepo setup
Does Netlify change requests from the browser during proxying?