Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Setup and Run a Gatsby Site

    Chris BiscardiChris Biscardi
    gatsbyGatsby
    >=2.16.5

    Our starting point is a fully functioning Gatsby site that we'll break down into themes.

    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Discuss

    Discuss

    Transcript

    Transcript

    Instructor: The advanced Gatsby themes workshop code project is setup into a set of branches. To start, we'll find the code URL, and we'll use that to clone the rebill. After cd-ing into the project directory, we can use ls to see our project setup.

    Note that this is a Gatsby project, so we have a number of Gatsby dash files as well as a yarn.lock indicating that we're using Yarn. This is important because we're about to use Yarn workspaces, which MPM does not have an equivalent for. You can run Yarn to install the dependencies.

    After installing the dependencies we can take a look at the scripts in the package json. Note that we have three scripts here, develop, build, and clean that are associated with Gatsby develop, Gatsby build and Gatsby clean respectively. We can use Yarn develop to start our project.

    Note that, while the project started up, we see a number of errors, including, Unknown field 'allShopifyProduct' on query, 401 Unauthorized errors for our WordPress plugin, and GraphQL query errors from the Shopify plugin.

    To fix these errors, we'll have to make two adjustments. Open up gatsby-config, find the location that has the gatsby-source-shopify plugin, and where it says Shop Name, replace it with your shop name that we got in the Shopify setup video. In my case, it's Corgi Supply, Incorporated.

    Scroll down and find the gatsby-source-WordPress plugin. You'll need the URL to your WordPress site. In this case, mine is advancedthemescourse.home.blog. Remember, this is the free domain that we chose when we were setting up our WordPress site. All the other configuration is included in process.env variables.

    After saving that, we have to create one more new file. This file will be called .env.development, and it will be in the root of our project.

    . env.development will include a number of our variables that we got from the previous setup videos for WordPress and Shopify, including the WordPress client secret, the WordPress client ID, the email and the password for our WordPress account, and the Shopify access token. Remember that this is storefront access token, and not the admin API token.

    If we save that file and run the site again, we can see that we have far fewer errors. Note that some of the 401 Unauthorized calls can be fixed, but they don't matter for us right now. Note that the Shopify calls all passed and we see times for each of them. The GraphQL query errors are now gone.

    If you open the site, you can test that the WordPress posts came in, by looking at the blog. You should have two posts, if you followed the WordPress setup guide. Note that also in the SWAG store, we'll see our Corgis, or whatever product you set up with the variance. You've now successfully set up the site.

    We'll gradually build this site into a set of themes over the course of this workshop.