Hosting two sites at one URL - status codes - monorepo

Hello Community,

I am having a custom Python script which can generate either one, or both, of two language versions of my site. The latter behavior appears to also take place in case of generating with Hugo Multilingual.

i want these version to function under two separate domains — kind of like Hugo Multilingual Multihost: https://gohugo.io/content-management/multilingual/#configure-multilingual-multihost .

i don’t think i want other-language.example.com to redirect to main.example.com/other-language/ , even if the path would be just two-letter

The solutions that can be:

  • generator, in a single deployment, generates two publish directories, netlify assigns one to one to one domain and the other to the other domain. If only it was supported by netlify configuration, if only there was some netlify.toml option maybe.
  • generator generates a site depending on a SITELANG environment variable, so there are two deployments but on one site (as in, site the netlify entity), maybe slightly faster because totaling to kinda one-and-a-half because cloning just once, just executing twice. If only it was supported by netlify configuration, if only there was some netlify.toml option maybe.
  • generator generates a site depending on a SITELANG environment variable, two netlify sites are created and connected to the same repository
  • generator generates a site depending on which language branch are we in, and we either create two separate sites for that or we use branch deployments

In my netlify.toml i also have, having two domains (language versions) a.example.com and b.example.com, a 301 force redirect from example.com/* to a.example.com/:splat

hi @ArchieT - glad you found us! I made a few edits to your post in order to make it more readable for others who come along.

Thanks for sharing your ideas around solutions - is there a specific question you are asking here or needing help on?

hey,

glad you found us! I made a few edits to your post in order to make it more readable for others who come along.

the post is now locked from editing. two-letter wasn’t supposed to be a code but a natural language word. in the last paragraph, to is not a code keyword either.

Thanks for sharing your ideas around solutions - is there a specific question you are asking here or needing help on?

yes, there are four (five) possible solutions, and the best one and second best one that would be better than the other two seem impossible. Just, do i have create two sites or mess up with two branches (if branch deployment is even possible without a dns wildcard record in netlify dns)? git is no darcs or pijul, so i would have to do non-ff merges every single push just for one variable to be different

@ArchieT,

Another option would be to have your build command build both versions of your site and put them in a subfolder in your publish directory (for example, /public/en and /public/es). If you have both subdomains added as domain aliases to you site, you can then create _redirects file to serve the proper language based on the subdomain.

Like:

https://en.example.com/* /en/:splat 200
https://es.example.com/* /es/:splat 200

This would allow you to have a single site with two language version served on different subdomains. You can even try using language-based redirects on top of the redirect I mentioned. Let me know what you think.

1 Like

so, 301|302|303 [[redirects]]/_redirects change the URL, but any other statuscode are just server-side rewrite, i.e. invisible to the user in the browser’s url field, right? Haven’t tested yet, but I guess that is an acceptable solution (as even the drawback of users being able to access the paths that are meant to be unaccessible otherwise than as a result of such a rewrite is a negligible one, and maybe even mitigable? by some more “redirects” or “redirects”-rewrites maybe?). Thanks!

That statement is not correct. Only status code 200 is a silent/transparent rewrite.

1 Like

This article also talks about the general pattern of how to host two codebases at the same hostname: