Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 Page handled differently by some static site #2267

Closed
thisiscam opened this issue Sep 28, 2017 · 3 comments
Closed

404 Page handled differently by some static site #2267

thisiscam opened this issue Sep 28, 2017 · 3 comments
Labels
type: documentation An issue or pull request for improving or updating Gatsby's documentation type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@thisiscam
Copy link
Contributor

I noticed that when I access http://gatsbyjs.github.io/gatsby-starter-blog/none, I can see the layout component is wrapped around the 404 page.

How can we augment gatsby's core to achieve the above effect? Specifically, seems like if we are hosting on something like surge or a simple apache server, the server will server 404.html directly, instead of going through gatsby's routing?

@m-allanson
Copy link
Contributor

For surge it looks like you need to create your own 404.html page. Gatsby should handle this if you create a page at /404

create a page whose path matches the regex /404*. Most often you’ll just want to create a React component page at src/pages/404.js.

There's a bit more info on the Gatsby docs: https://www.gatsbyjs.org/docs/add-404-page/

@thisiscam
Copy link
Contributor Author

The question I have is that I don't really understand the behavior of 404.js.

If I have 404.js, it will be compiled into 404.html happily. Yet when I hit a non existing page, the layout component disappears and JS is not loaded correctly.

I can still access mysite/404 directly, and the result page will be wrapped in layout component again..

Am I missing something here? What is the intended behavior of that standalone 404.html?

Lastly, this could be related: if I goto mysite/index.html , the server will serve only that html file for some reason I'm not able to understand.. maybe its just how it works, but generally I would expect "mysite.com/index.html" and "mysite.com/" to be functioning similarly?

@sebastienfi sebastienfi added API/Plugins type: documentation An issue or pull request for improving or updating Gatsby's documentation type: question or discussion Issue discussing or asking a question about Gatsby labels Oct 1, 2017
@KyleAMathews
Copy link
Contributor

Closing this issue as it's fairly old and we have far too many open issues! If you have additional problems in this area, please open a new issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation An issue or pull request for improving or updating Gatsby's documentation type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

4 participants