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

    Automatically Create Pages in Gatsby

    Amberley RomoAmberley Romo
    gatsbyGatsby

    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

    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
    Transcript

    Transcript

    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.

    Discuss

    Discuss