Combine multiple git repos within the same domain, is this possible?

EDITED:

The whole question below can be rephrased like this:

Can I combine multiple gatsby sites hosted in different repos in the same domain?

Like having site 1 in www.mydomain.com
And then site 2 in www.mydomain.com/site2
And then site 3 in www.mydomain.com/site3

Is that possible?




[ previous question ↓↓↓]




Title: Showing a 2nd domain as an address of a 1st domain: Redirect vs Rewrite with relative paths of a gatsby site to another gatsby site, how to?

I am trying to set the following scenario, but I’m unsure about whether this is feasible or not, this is

Showing a 2nd (netlify) domain as an address of a 1st (netlify) domain

I start with this


  1. DNS
    www.kuworking.com domain pointing to kuworking.netlify.com
  2. NETLIFY
    Redirecting kuworking.netlify.com/* to www.kuworking.com/*

_

[[redirects]]
  from = "https://kuworking.netlify.com/*"
  to   = "https://www.kuworking.com/:splat"
  status = 301
  force = true

This works as expected


Now I’d like that someone that types themes.kuworking.com goes to www.kuworking.com/themes

  1. DNS
    themes.kuworking.com domain pointing to kuworking.netlify.com

  2. OPTION
    Redirecting themes.kuworking.com to www.kuworking.com/themes

_

[[redirects]]
  from   = "https://themes.kuworking.com"
  to = "https://www.kuworking.com/themes"
  status = 301
  force = true

This works, but the url gets changed, so I can try a rewrite

  1. OPTION
    Rewriting themes.kuworking.com to www.kuworking.com/themes

_

[[redirects]]
  from   = "https://themes.kuworking.com"
  to = "https://www.kuworking.com/themes"
  status = 200
  force = true

This works, the url doesn’t change


Now I have a second domain https://kuworking-theme-blog-one.netlify.com

I’d like that when someone types https://themes.kuworking.com/blog-one goes to that address

  1. OPTION
    Redirecting themes.kuworking.com/blog-one to kuworking-theme-blog-one.netlify.com

_

[[redirects]]
  from   = "https://themes.kuworking.com/blog-one"
  to = "https://kuworking-theme-blog-one.netlify.com"
  status = 301
  force = true

This works, but again the url gets changed and I’d like that the url was kept as the original one, so let’s try a rewrite

  1. OPTION
    Rewriting themes.kuworking.com/blog-one to kuworking-theme-blog-one.netlify.com

_

[[redirects]]
  from   = "https://themes.kuworking.com/blog-one"
  to = "https://kuworking-theme-blog-one.netlify.com"
  status = 200
  force = true

And this works in the sense of not changing the url, but then all images and links from https://kuworking-theme-blog-one.netlify.com are lost since they use relative paths


So what to do?

  • Should I try to configure all paths as absolute paths in the 2nd site? (don’t really know how to do it with gatsby)

  • Or should I configure a redirect in the 2nd site? Would that work?

  • Or should I deploy the 2nd site within the 1st site in a folder? Is this possible?

This article explains best practices for multiple-sites-one-hostname:

Should work well for your use case!

Yes, that’s exactly what I want to achieve

:white_check_mark: parent/blog/post-1 >>> second-site/blog/post-1

With your link I’ve got it working with the redirect and the basePath so that

:white_check_mark: second-site/post-1 >>> second-site/blog/post-1
:white_check_mark: parent/blog/post-1 >>> second-site/blog/post-1

But haven’t been able to do the same with the images

post-1 points to images in second-site/static/img.jpg, and this transforms into parent/static/img.jpg where the images don’t exist

I’m not sure how I could change these urls, since I’m not using the path-prefix shown here https://www.gatsbyjs.org/docs/path-prefix/ but using a basePath when programmatically generating the static pages

I’ve been giving rounds the last hours without success, so without more info I for now have to abandon this and hope for a future easier implementation (from Netlify or from Gatsby)

Thanks again!

While I’m not able to debug in depth today, for a stopgap, you could copy them into /parent during deploy? We don’t store two copies or anything, but then they’ll be where the config wants to see them.