⚠️ This lesson is retired and might contain outdated information.

Automatically Create Pages in Gatsby

Amberley Romo
InstructorAmberley Romo
Share this video with your friends

Social Share Links

Send Tweet

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

Amberley Romo: [00:00] 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.

[00:12] 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.

[00:30] 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.

[00:49] 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.