diff --git a/docs/docs/recipes.md b/docs/docs/recipes.md index 40580403ff9ea..9c56d0f6a8117 100644 --- a/docs/docs/recipes.md +++ b/docs/docs/recipes.md @@ -161,12 +161,53 @@ To wrap pages with layouts, use normal React components. ## Deploying -Showtime. +Showtime. Once you are happy with your site, you are ready to go live with it! + +### Preparing for deployment + +#### Prerequisites + +- A [Gatsby site](/docs/quick-start) +- The [Gatsby CLI](/docs/gatsby-cli) installed + +#### Directions + +1. Stop your development server if it is running (`Ctrl + C` on your command line in most cases) + +2. For the standard site path at the root directory (`/`), run `gatsby build` using the Gatsby CLI on the command line. The built files will now be in the `public` folder. + +```shell +gatsby build +``` + +3. To include a site path other than `/` (such as `/site-name/`), set a path prefix by adding the following to your `gatsby-config.js` and replacing `yourpathprefix` with your desired path prefix: + +```js:title=gatsby-config.js +module.exports = { + pathPrefix: `/yourpathprefix`, +} +``` + +There are a few reasons to do this--for instance, hosting a blog built with Gatsby on a domain with another site not built on Gatsby. The main site would direct to `example.com`, and the Gatsby site with a path prefix could live at `example.com/blog`. + +4. With a path prefix set in `gatsby-config.js`, run `gatsby build` with the `--prefix-paths` flag to automatically add the prefix to the beginning of all Gatsby site URLs and `` tags. + +```shell +gatsby build --prefix-paths +``` + +5. Make sure that your site looks the same when running `gatsby build` as with `gatsby develop`. By running `gatsby serve` when you build your site, you can test out (and debug if necessary) the finished product before deploying it live. + +```shell +gatsby build && gatsby serve +``` + +#### Additional Resources - Walk through building and deploying an example site in [tutorial part one](/tutorial/part-one/#deploying-a-gatsby-site) -- Learn how to make sure your site is configured properly to be [searchable, shareable, and properly navigable](/docs/preparing-for-site-launch/) - Learn about [performance optimization](/docs/performance/) -- Read about [other deployment related topics](/docs/deploying-and-hosting/) +- Read about [other deployment related topics](/docs/preparing-for-deployment/) +- Check out the [deployment docs](/docs/deploying-and-hosting/) for specific hosting platforms and how to deploy to them ## Querying data