Getting Started with Gatsby
A React Love Story
Ryan Harris
Software Engineer @ Guru
@ryan_c_harris
Ivana Veliskova
Mansi Pathak
Ryan Yurkanin
“Confessions of an Impostor”
PhillyXP // Last Week
“Component Tree Visualization in React”
Philadelphia JavaScript Developers // Last Week
“Why React Hooks, and how did we even get here?”
RQ React // Later Tonight
@ryan_c_harris
© 2018 Guru Technologies, Inc.
We are currently hiring.
@ryan_c_harris
© 2018 Guru Technologies, Inc.
We are currently hiring.
@ryan_c_harris
© 2018 Guru Technologies, Inc.
“This guy looks familiar...”
~ Maybe You
@ryan_c_harris
© 2018 Guru Technologies, Inc.
It us.
@ryan_c_harris
© 2018 Guru Technologies, Inc.
It us.
© 2018 Guru Technologies, Inc.
Shut up and get on with the Gatsby stuff already!
~ Definitely You
@ryan_c_harris
© 2018 Guru Technologies, Inc.
You got it!
@ryan_c_harris
© 2018 Guru Technologies, Inc.
What we’re going to talk about today
What Gatsby is (and why use it)
Working with Gatsby
How to deploy your statically generated Gatsby site
@ryan_c_harris
© 2018 Guru Technologies, Inc.
What is Gatsby?
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Definition:
A static site generator takes source files and generates an entirely static website.
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Gatsby & GraphQL
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Why use Gatsby?
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Advantages of using Gatsby
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Advantages of using Gatsby
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Advantages of using Gatsby
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Advantages of using Gatsby
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Advantages of using Gatsby
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Advantages of using Gatsby
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Advantages of using Gatsby
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Advantages of using Gatsby
@ryan_c_harris
© 2018 Guru Technologies, Inc.
How does React fit in?
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Everything is a component!
@ryan_c_harris
© 2018 Guru Technologies, Inc.
GIF break!
@ryan_c_harris
© 2018 Guru Technologies, Inc.
GIF break!
To talk about plugins and starters.
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Plugins
Additional Gatsby functionality
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Starters
Gatsby site boilerplates
@ryan_c_harris
© 2018 Guru Technologies, Inc.
package.json
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Who is using Gatsby?
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Examples of Gatsby in production
Dan Abramov’s (React team) blog
Ryan Yurkanin (Lead @ Guru) blog
Official React documentation from Facebook
Shameless self-promo :-)
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Working with Gatsby
@ryan_c_harris
© 2018 Guru Technologies, Inc.
> npm install -g gatsby-cli
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Gatsby commands
> gatsby new [repo name] [starter repo]
Create a new Gatsby project
> gatsby develop
Start up dev server
> gatsby build
Compile source finals, output files for production
> gatsby serve
Serve files build with gatsby build
@ryan_c_harris
© 2018 Guru Technologies, Inc.
> gatsby new my-blog [repo_url]
Create a new site using the official Gatsby blog starter
*In this case, https://github.com/gatsbyjs/gatsby-starter-blog
@ryan_c_harris
© 2018 Guru Technologies, Inc.
PSA: Remember to npm install
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Gatsby file structure
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Gatsby file structure
All your working files
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Gatsby file structure
All your working files
Build files ready to be deployed to production
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Gatsby file structure
All your working files
Build files ready to be deployed to production
Gatsby plugins & npm packages
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Gatsby file structure
All your working files
Build files ready to be deployed to production
Gatsby plugins & npm packages
Site and plugin configuration
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Gatsby file structure
All your working files
Build files ready to be deployed to production
Gatsby plugins & npm packages
Site and plugin configuration
GraphQL and data configuration
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Gatsby file structure
Gatsby cache files
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Gatsby file structure
Gatsby cache files
* You may need to delete this directory
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Gatsby file structure
Gatsby cache files
* You may need to delete this directory
Included in the .gitignore
@ryan_c_harris
© 2018 Guru Technologies, Inc.
> gatsby develop
Fire up your local development server
@ryan_c_harris
© 2018 Guru Technologies, Inc.
http://localhost:8000
@ryan_c_harris
© 2018 Guru Technologies, Inc.
http://localhost:8000/___graphql
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Let’s live code!
Cause that always goes well.
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Deploying Gatsby
@ryan_c_harris
© 2018 Guru Technologies, Inc.
“I love Daisy... but I hate deploying code!”
@ryan_c_harris
© 2018 Guru Technologies, Inc.
> gatsby build
Run this command to build your
production files
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Places to host your built site
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Places to host your built site
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Places to host your built site
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Places to host your built site
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Places to host your built site
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Deploy to GitHub Pages
@ryan_c_harris
© 2018 Guru Technologies, Inc.
> npm install gh-pages
This package makes deploying your site to GitHub Pages easier
@ryan_c_harris
© 2018 Guru Technologies, Inc.
@ryan_c_harris
© 2018 Guru Technologies, Inc.
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Thank You
Ryan Harris
@ryan_c_harris
Software Engineer @ Guru
@ryan_c_harris
© 2018 Guru Technologies, Inc.
Questions?
Ryan Harris
@ryan_c_harris
Software Engineer @ Guru
@ryan_c_harris
© 2018 Guru Technologies, Inc.