Skip to content

Adding 404 page to a custom path #23792

Answered by darrowby385
uilianries asked this question in General
Discussion options

You must be logged in to vote

Hi, @uilianries!

I’m afraid GitHub Pages only supports storing a custom 404 page in the root of your publishing source.

That said, rather than creating a unique HTML file at this location, and within it a JavaScript redirect, you could instead consider using a symlink.

By creating a symlink to en/latest/404.html, you can save yourself the hassle and inelegance of the redirect. Instead, GitHub Pages will simply follow the symlink during the build process, and implement your desired custom 404 page.

On macOS, Linux, or Git Bash, you can create the necessary symlink by running this command from the root of your repository’s gh-pages branch:

ln -s en/latest/404.html

I hope that helps!

Friday

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants