Reputation: 13
I am willing to generate Gatsby website but I need to deploy this in an on-premise app. So technically I need to put the public folder and link the index.html wherever I want. But, when we generate build, the index.html doesn't show the whole website. Is there a way I can make it work?
In Gatsby freamework, we usually say npm run develop and test our website on localhost:8000. Now let's say npm run build so that build will generate.
But I want to use the index.html as full functional website like we generally do with any website development in an older way of HTML and CSS.
Upvotes: 1
Views: 962
Reputation: 2150
Depending on how the index.html
file is written, sometimes it’s not sufficient to open the file locally in a web browser—this can be true even if you’re not using Gatsby. Instead, sometimes it still needs to be served by a web server.
What I imagine you’re seeing is that the index.html
page works, but then some of the links are “broken” because they don’t point to the right places in the context of just opening the index.html
file in your browser, but they actually will be correct in the real context of having the static site served by a web server.
To make that easier, Gatsby has a build-in command for serving an already built site. After running:
gatsby build
…in the terminal and it completes, run:
gatsby serve
Now Gatsby is serving the flat HTML, CSS, and JavaScript version of your project from the public/
folder at http://localhost:9000
for you to view. You can view source in the browser to see that this is the compiled result of your HTML file. Hope that’s helpful!
Upvotes: 2