Become a member
to unlock all features

Level Up!

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


    Automatically Create Pages in Gatsby

    Amberley RomoAmberley Romo

    Gatsby automatically turns React components located in src/pages into pages with URLs.

    This video will show you:

    • How to create a new component in src/pages to automatically create new pages in Gatsby.

    Further reading



    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




    Amberley Romo: I've already created the new Gatsby site using the Gatsby default starter. I'm running it locally. The default starter ships with a few pages already defined, as examples. Over here, you can see the index page.

    Over in our code, if we open up site, then source, then pages, and then this index.js file, this component is actually what's creating what you see here on the index page. Hi, people.

    Let's create a new page, just for example. We'll make it an about page and we'll just add a little bit of example content.

    Now, if we go back over here to our site running in development, and we hit the about route, we'll see this content that we just put into this component, in this about.js file. Gatsby will automatically turn any file in the source pages directory into a page.