How to host a gatsby site on custom domain subfolder?

Hi,

So I want to host different sites under a single custom domain using subfolders.

site 1: customdomain.com/site1/
site 2: customdomain.com/site2/

I looked at the documentation and googled but didn’t really understand. Is this possible?

Thanks.

do you mean something like a monorepo, potentially?

No, not something like this.

I’ve just added subdomains, and moved to other work. But I am curious how to host a gatsby site in domain.com/site.

Gatsby has a prefix option, but I couldn’t find the relevant setting in Netlify.

You’d set the publish directory to be “dir”, put your build’s output files in “dir/site/index.html” in git, and you’re good to go :slight_smile: !

You’ll want to make sure that matches with Gatsby’s expectation of where things go, and make sure that your single-page-app redirect rule:

…also targets that directory (probably something like /site/* /site/index.html 301! if you wrote it manually)

1 Like

Thanks @fool. Finally I’m getting back to this topic.

Do you mean changing the publish directory to something like: blog/public/ or blog/ ?

I mean, make gatsby output in /directory/subdirectory (this is where your main index.html should be), and set it to /directory (which I guess should be empty, still not sure exactly what your goal is, but I think that would map) - so that we deploy /subdirectory/*.