⚠️ 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
Published 5 years ago
Updated 2 years ago

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.

egghead
egghead
~ 44 seconds ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today