

You basically have three options: a server config, a JavaScript location manipulation, or a refresh meta tag. The first thing I did was investigate other options for getting the browser to redirect to the index.html page. Template and Demo: If you want to skip the explanation and get the goods, here’s a template repo, and a test URL to see it in action. The gauntlet had been thrown down, and I decided to answer - and answer with vigor! One More Time, With FeelingĪfter sleeping on it, I thought to myself, “Self, we’re deep in dirty hack territory, so why don’t I make this hack even dirtier?!” To that end, I developed an even better hack that provides the same functionality and simplicity, while also preserving your website’s crawler juice - and you don’t even need to waste time duplicating your index.html file and renaming it to 404.html anymore! The following solution should work in all modern desktop and mobile browsers (Edge, Chrome, Firefox, Safari) and in Internet Explorer 10+.
APPHACK REPO CODE
However, the problem that some folks on Twitter correctly raised was that the 404.html page is still served with a status code of 404, which is not good for search engine crawlers. Turns out that many folks have experienced the same issue with GitHub Pages and liked the general idea. I took a first stab at an SPA hack simply by duplicating my index.html file and renaming the copy to 404.html. In case you weren’t aware, GitHub does provide one morsel of customization for your project website: the ability to add a 404.html file and have it served as your custom error page.

Currently, GitHub Pages doesn’t offer a route-handling solution the Pages system is intended to be a flat, simple mechanism for serving basic project content.

This is table-stakes because such apps require all requests to be routed to one HTML file, unless you want to copy the same file across all of your routes every time you make a change to the project. For some time now, I’ve wanted the ability to route paths for a GitHub Pages website to its index.html for handling as a single-page app (SPA).
