I just created a new website with GatsbyJS and followed the tutorial to deploy it on surge.sh. Everything went smoothly but when I contacted my hosting provider, they informed me that I have to purchase a VPS with full root access in order to host a one-page website made with Gatsby. Is there a way to upload the site to my shared hosting account as an HTML file with its resources? Any tutorial, if it exists, will be appreciated.
At the root of your GatsbyJS project, run the gatsby build command, it should build a directory called public. Inside that directory is your whole static website. So, if you are able to put it on a server, it should be working.
Thank you for the info, tulphoon. Unfortunately, my hosting provider has just informed me that their shared hosting servers cannot run sites that rely on NodeJS.
You鈥榣l need to upload the content of the public directory e.g. via FTP. Nodejs is not needed.
Thank you LeKoArts. I'll have to test this!
You were right. I just uploaded the site via FTP and there were no issues. Thank you!
@ygspasov Closing this as your question seems to be answered. Please feel free to reopen if you're still running into problems!
the problem is with that you cannot have state on shared hosting,i tried a simple counter application and try it to host with xampp and it doesn't work.
Hi @dksami ,
please open a new issue regarding your problem. The state is always handled in the memory of the browser so state should still work.
Well the thing was the prefix of asset, it was not pointing in the correct direction. i always thought that a Apache server cant handle the state. i was wrong.
State is always handled / managed by the client (JavaScript). React runs completely on the client side / in the browser, no server needed for that.
How is gatsby serve is any different, it doesn't needed prefix.
How is gatsby serve is any different
This is a local in-memory development server which directly mounts the dist / public folder on the root folder.
Please ask further questions in the community on Discord.
Most helpful comment
You鈥榣l need to upload the content of the public directory e.g. via FTP. Nodejs is not needed.