diff --git a/docs/docs/porting-an-html-site-to-gatsby.md b/docs/docs/porting-an-html-site-to-gatsby.md new file mode 100644 index 0000000000000..6d29fc72e1be5 --- /dev/null +++ b/docs/docs/porting-an-html-site-to-gatsby.md @@ -0,0 +1,553 @@ +--- +title: Porting an HTML Site to Gatsby +--- + +This guide focuses on the parts of Gatsby that are applicable to a static website. For a more comprehensive walk through Gatsby's features check out the [Gatsby tutorial](/tutorial/). By following the example on this page, you will complete the key stages of porting an HTML website to Gatsby and establish your Gatsby development workflow. + +**Note:** This guide can also be used to migrate a section of a site, to be served next to existing files. Pay extra attention to the section on [hosting](#hosting-the-new-website) for guidance. + +## Getting Started + +Here is the structure of an example static HTML/CSS website that this guide will walk through porting: + +``` +website-domain + ├── assets + │ ├── favicon.ico + │ ├── person.png + │ ├── normalize.css + │ └── style.css + ├── index.html + ├── 404.html + ├── about.html + ├── contact.html + ├── services + │ ├── index.html + │ ├── growing.html + │ ├── cleaning.html + │ └── shrinking.html + └── who + ├── index.html + ├── ellla-arborist.html + ├── marin-leafer.html + └── sam-surgeon.html +``` + +### Assumptions + +The example site uses global CSS files (`style.css` and `normalize.css`); styling structures like [Sass](/docs/sass/) architectures or [CSS-in-JS](/docs/css-in-js/) can be accommodated but will not be covered here. + +No [client-side](/docs/glossary#client-side) JavaScript (e.g jQuery etc.) is on the example site. If your site includes client-side JavaScript libraries and functionality, Gatsby may conflict with it at [build](/docs/glossary#build) time if not handled or removed when porting. Learn more about [Debugging HTML Builds](/docs/debugging-html-builds/). + +### Development environment + +Gatsby generates websites and web applications for production through a compilation and build process, and it also has tools optimized for local development. To set up the Gatsby [CLI](/docs/glossary#cli) and development environment (if you haven't already) check out [Part Zero of the Gatsby tutorial](/tutorial/part-zero/). + +### Gatsby Project + +Now that you are set up, you can use the Gatsby and npm CLI tools in your terminal to get this site ported! +Make a new project using the Gatsby hello world starter with the following command: + +```shell +gatsby new gatsby-site https://github.com/gatsbyjs/gatsby-starter-hello-world +``` + +You should now have a folder called `gatsby-site` containing a basic Gatsby application. Open the new folder in your code editor and `cd` (change directory) into the folder in your terminal to continue: + +```shell +cd gatsby-site +``` + +The `/src` folder contains most of the front-end code for the Gatsby site. In the Gatsby [build](/docs/glossary#build) process, [every component file in the `/src/pages` folder will automatically create an HTML page](/docs/recipes/#creating-pages-automatically). In your new Gatsby application, the only page created is from the index page component in `/src/pages/index.js`: + +```jsx:title=/gatsby-site/src/pages/index.js +import React from "react" + +export default () =>
Ella
+