rossjrw / pr-preview-action

GitHub Action that deploys a pull request preview to GitHub Pages, similar to Vercel and Netlify, and cleans up after itself.
https://github.com/marketplace/actions/deploy-pr-preview
MIT License
255 stars 39 forks source link

Support custom 404 previews #34

Closed xander-marjoram closed 1 year ago

xander-marjoram commented 1 year ago

Hello, thanks for making this great Action. I'm trying to test adding a new 404 page and wondered if I'm going about it the wrong way.

The docs for GitHub Pages say that you can have a custom 404 page by putting a 404.html in the root of the deployment.

If I create a 404 page and add it as part of a PR, I can see it by going to https://[owner].github.io/[repo]/pr-preview/pr-[number]/404.html but it does not function as a catch-all, for example when I go to https://[owner].github.io/[repo]/pr-preview/pr-[number]/this/page/does/not/exist I see the default GitHub Pages 404 instead of mine. Would it be possible to get this working?

rossjrw commented 1 year ago

I don't think so, no. 404s get redirected to 404.html at the root of your site.

If you were using e.g. an Apache web server, you could change the config to have a different 404 page per directory. GitHub Pages doesn't allow you that level of customisation.