skip to Main Content

I’m new to react and gatsby so I am following the gatsby tutorial online. I was steadily working through Part 2 when I ran into problem. On the tutorial they have created a second javascript file called about.js and added a basic component and exported it at the end. I did all that, granted I typed it all out myself and changed up the text in the html stuff a little but nothing that should affect the outcome of the program too much. But when I go to http://localhost:8000/about/ I get a 404 error and the gatsby development 404 page. To make things worse at the bottom it has a list of pages that it recognizes and http://…/about/ is one of them. Anyone know what is happening here? I will put the code for the home and about page along with screenshots below.

    import * as React from 'react'
    import { Link } from 'gatsby'

    const IndexPage = () => {
      return (
        <main>
          <h1>This is my header</h1>
          <p>This is my paragraph, WOWZA!</p>  
          <Link to='/about'>About</Link>
        </main>
      )
    }

    export default IndexPage

http://localhost:8000/

    import * as React from 'react'
    import { Link } from 'gatsby'

    const AboutPage = () => {
      return (
        <main>
          <h1>About Me</h1>
          <Link to="/">Back to Home</Link>
          <p>Hi there! I'm the proud creator of this site, which I built with Gatsby.</p>
        </main>
      )
    }

    export const Head = () => <title>About Me</title>

    export default AboutPage

http://localhost:8000/about/

I tried rerunning gatsby develop to see if that did anything but it didn’t.

2

Answers


  1. I do not know that framework, but with a quick glance it looks opinionated. If you don’t follow their dogma, things probably aren’t going to work. Per example, I noticed that the framework serves anything in the pages folder. From your 404 response, it seems that it goes up a level to find about.js. Can you confirm that about.js is located in the pages folder?

    Login or Signup to reply.
  2. To see the url with /about on web, have to use Route.

    Instead of element, can use Component.

    <Route path="/about" element={} />

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search