Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: expand deploy recipe #15605

Merged
merged 19 commits into from
Jul 20, 2019
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 45 additions & 3 deletions docs/docs/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,54 @@ 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!

tom-raley marked this conversation as resolved.
Show resolved Hide resolved
#### Prerequisites

-A Gatsby site ([check out the Tutorial if you don't yet have a Gatsby site](/tutorial/))
tom-raley marked this conversation as resolved.
Show resolved Hide resolved
-The [Gatsby CLI](/docs/gatsby-cli)
tom-raley marked this conversation as resolved.
Show resolved Hide resolved

#### Directions

1. Stop your development server if it is running (`Ctrl + C` on your command line in most cases)

2. If you want the standard path prefix for your site (`/`), run `gatsby build` using the Gatsby CLI on the command line. The files you need to copy to your server will now be in the `public` folder.
tom-raley marked this conversation as resolved.
Show resolved Hide resolved

```shell
gatsby build
```

3. If you'd like to have the index of your site be at a path other than `/`, set a path prefix by adding the following to your `gatsby-config.js` and replacing `yourpathprefix` with your desired path prefix:
tom-raley marked this conversation as resolved.
Show resolved Hide resolved

```js:title=gatsby-config.js
module.exports = {
pathPrefix: `/yourpathprefix`,
}
```

There are a few reasons you might want to do this--for instance, if you are hosting a blog built with Gatsby on a domain where you are running another site not built on Gatsby. The main site would direct to `example.com`, and by setting a path prefix you can have `example.com/blog` load your Gatsby site directly.
tom-raley marked this conversation as resolved.
Show resolved Hide resolved

Once your path prefix is set in your `gatsby-config.js`, run `gatsby build`, but make sure to add the `--prefix-paths` flag, like so:
tom-raley marked this conversation as resolved.
Show resolved Hide resolved

```shell
gatsby build --prefix-paths
```

With this flag added, Gatsby will automatically add your path prefix to the beginning of all of your site's URLs and will automatically update all `<Link>` tags as well.
tom-raley marked this conversation as resolved.
Show resolved Hide resolved

4. It is generally helpful to make sure that your site looks the same when running `gatsby build` as it did when running `gatsby develop`. By running `gatsby serve` after you build your site, you can test out (and debug if necessary) the finished product before deploying it live.
tom-raley marked this conversation as resolved.
Show resolved Hide resolved

```shell
gatsby serve
tom-raley marked this conversation as resolved.
Show resolved Hide resolved
```

5. From here, you can either copy the files in your `public` folder directly to your server, or deploy to one of many popular servers. Check out the [deployment docs for specific hosting platforms and how to deploy to them](/docs/deploying-and-hosting/).
tom-raley marked this conversation as resolved.
Show resolved Hide resolved

#### 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/)

tom-raley marked this conversation as resolved.
Show resolved Hide resolved
## Querying data

Expand Down