I have a simple project working nicely using JSX / React / Gatsby.
I have a pre-existing page (think landing page) in HTML in another project, quite complex, nicely styled using Bootstrap 4, let's call it LandingPage.html and an associated LandingPage.css.
I would like to add the landing page to my Gatsby site. So that for example when navigating to localhost:3000/LandingPage.html the landing page gets shown, properly styled etc.
I am not clear whether I have to fully convert my pre-existing HTML into a react component / JSX? Or whether I can just serve the LandingPage.html (and associated styling files) by placing it somewhere sensible in my Gatsby project structure? Or whether I have to create a react "wrapper" that at "run time" reads in the content of LandingPage.html and LandingPage.css?
Note: I've tried just putting the LandingPage.html and LandingPage.css into the /public folder and actually that does work! So maybe I've answered my own question. But is the the right way to do it?
Gatsby is the best way to develop static webpages with React. Gatsby sites are incredibly fast to build, and they are equally quick in performance.
Gatsby, on the other hand, is a static progressive web app (PWA) generator that offers code and data splitting out of the box. To boost performance, Gatsby loads only critical HTML, CSS, JavaScript, and other data.
Gatsby enables developers to build fast, secure, and powerful websites using a React-based framework and innovative data layer that makes integrating different content, APIs, and services into one web experience incredibly simple.
Gatsby uses html. js in the src folder. Not index. html like most react projects.
As of Gatsby v2 (don't know about previous versions), it is maybe more consistent to add the file to the /static
folder.
According to the docs, the /public
folder is meant to be generated automatically when building the site and should be added to .gitignore
.
Files added to the /static
folder will be copied to /public
when building the site so it should have the same effect. More info here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With