Skip to content

Commit 482ea8d

Browse files
piehsidharthachatterjee
authored andcommitted
fix(gatsby): handle /404/, /404, 404/ or 404 page paths (#15615)
1 parent e8d3529 commit 482ea8d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

docs/docs/add-404-page.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "Adding a 404 Page"
33
---
44

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

99
Gatsby ensures that your 404 page is built as `404.html` as many static hosting

packages/gatsby/src/internal-plugins/prod-404/gatsby-node.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ exports.onCreatePage = ({ page, store, actions }) => {
33
// Copy /404/ to /404.html as many static site hosts expect
44
// site 404 pages to be named this.
55
// https://www.gatsbyjs.org/docs/add-404-page/
6-
if (!created404 && page.path === `/404/`) {
6+
if (!created404 && /^\/?404\/?$/.test(page.path)) {
77
actions.createPage({
88
...page,
99
path: `/404.html`,

0 commit comments

Comments
 (0)