For some pages, i want to to change the URL path in the router to not map directly to the path on the filesystem.
These pages will be placed on subdomains, all such pages are building to a folder /test/, we get /test/subdomain1/index.html, /test/subdomain2/index.html, /test/subdomain3/index.html etc.
Redirection is configured by Nginx, but gatsby take path from gatsby-script-loader and a page subdomain.domain.com redirected to subdomain.domain.com/test/subdomain1/index.html
I saw that a similar question about path rewriting was raised in #3113 and #383 but there is no solution to these questions.
Is there any solution to this problem? Thanks!
You should be able to do this using path prefixes.
Read more about this at https://www.gatsbyjs.org/docs/path-prefix/
Wow, how quickly closed the question)
I found a solution to this problem in 4337, the plugin https://github.com/wardpeet/gatsby-plugin-static-site helps to remove unnecessary redirects.
袙ut I'm not sure this is the best solution.
@sidharthachatterjee, 褋ould you describe in more detail how path-prefix can help me? I need to build pages for the main domain in one project, as well as pages for all subdomains in the same project, in the folders demo/subdimain1, demo/subdimain2, demo/subdimain3. There are many subdomains and they are of the same type. All redirect will will be made Nginx.
This task is more like building several app in one project, but in several similar questions I did not find simple solution to this problem.
@TibiTotoro Sorry for closing this too soon!
Let me elaborate. Path prefixes let you host at something other than at the the root (/) of the domain.
For example in your case, you could build the sites for each sub domain independently and put in folders demo/subdimain1, demo/subdimain2, demo/subdimain3. For this, you would set the path prefix as /subdimain1, /subdimain2 and /subdimain3 respectively.
I understand correctly that you propose to run build several times, each time with your own path-prefix and put the files into different folders? Is there any way to automate this (there are many subdomains)? Is there any way to avoid duplication of static content such as images and documents that are the same for subdomains? If I duplicate static content 30-40 times, the output project will be terribly large.
In this moment i build project once, create pages for subdomains by createPages in gatsby-node.js, disable gatsby routing and set up redirects by nginx, 胁ut i think, this may lead to problems.
@sidharthachatterjee: path-prefix allows to host at something other than /, but it doesn't allow you to host at something other than / while, at the same time, _serving_ at a different URL where it's in the filesystem, because first thing gatsby app does is a "canonical check":
https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/cache-dir/production-app.js#L69
in #4337 there was a proposal to introduce a config variable to disable such redirect, but was closed in favor of a workaround that doesn't work anymore.
Hiya!
This issue has gone quiet. Spooky quiet. 馃懟
We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contributefor more information about opening PRs, triaging issues, and contributing!
Thanks for being a part of the Gatsby community! 馃挭馃挏
Hey again!
It鈥檚 been 30 days since anything happened on this issue, so our friendly neighborhood robot (that鈥檚 me!) is going to close it.
Please keep in mind that I鈥檓 only a robot, so if I鈥檝e closed this issue in error, I鈥檓 HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!
Thanks again for being part of the Gatsby community!