From 96aa8900b0762137ab820408d982420416ce8d45 Mon Sep 17 00:00:00 2001 From: Tom Raley Date: Fri, 19 Jul 2019 20:44:47 -0500 Subject: [PATCH] Docs: expand deploy recipe (#15605) * initial commit expanding deploy recipe * finished expanding deploy recipe * chore: format * Shorten prerequisites in docs/docs/recipes.md Co-Authored-By: Marcy Sutton * Clean up path prefix steps docs/docs/recipes.md Co-Authored-By: Marcy Sutton * Clean up step #3 in docs/docs/recipes.md Co-Authored-By: Marcy Sutton * Clean up #4 in docs/docs/recipes.md Co-Authored-By: Marcy Sutton * Clean up #5 in docs/docs/recipes.md Co-Authored-By: Marcy Sutton * Shorten build/serve command in deploy recipe docs/docs/recipes.md Co-Authored-By: Marcy Sutton * Update docs/docs/recipes.md Co-Authored-By: Marcy Sutton * Shorten path prefix deploy recipe section docs/docs/recipes.md Co-Authored-By: Marcy Sutton * Remove actual deployment from deploy recipe docs/docs/recipes.md Co-Authored-By: Marcy Sutton * Clean up prefix-paths section deploy recipe docs/docs/recipes.md Co-Authored-By: Marcy Sutton * Update deploy recipe formatting Co-Authored-By: Marcy Sutton * Update formatting on deploy recipe CLI bullet point Co-Authored-By: Marcy Sutton * Added deploy recipe header Co-Authored-By: Marcy Sutton * chore: format --- docs/docs/recipes.md | 47 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) 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