Skip to content

Commit

Permalink
fix(gatsby): handle /404/, /404, 404/ or 404 page paths (#15615)
Browse files Browse the repository at this point in the history
  • Loading branch information
pieh authored and sidharthachatterjee committed Jul 11, 2019
1 parent e8d3529 commit 482ea8d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/docs/add-404-page.md
Expand Up @@ -3,7 +3,7 @@ title: "Adding a 404 Page"
---

To create a 404 page create a page whose path matches the regex
`/404*`. Most often you'll want to create a React component page at
`^\/?404\/?$` (`/404/`, `/404`, `404/` or `404`). Most often you'll want to create a React component page at
`src/pages/404.js`.

Gatsby ensures that your 404 page is built as `404.html` as many static hosting
Expand Down
Expand Up @@ -3,7 +3,7 @@ exports.onCreatePage = ({ page, store, actions }) => {
// Copy /404/ to /404.html as many static site hosts expect
// site 404 pages to be named this.
// https://www.gatsbyjs.org/docs/add-404-page/
if (!created404 && page.path === `/404/`) {
if (!created404 && /^\/?404\/?$/.test(page.path)) {
actions.createPage({
...page,
path: `/404.html`,
Expand Down

0 comments on commit 482ea8d

Please sign in to comment.