Skip to content

Instantly share code, notes, and snippets.

@orbitbot
Created May 14, 2016 11:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orbitbot/6baa0b9591b0065859c53168a5ba63ce to your computer and use it in GitHub Desktop.
Save orbitbot/6baa0b9591b0065859c53168a5ba63ce to your computer and use it in GitHub Desktop.
GH Pages SPA hack
http://www.backalleycoder.com/2016/05/13/sghpa-the-single-page-app-hack-for-github-pages/
<script>
sessionStorage.redirect = location.href;
</script>
<meta http-equiv="refresh" content="0;URL='http://MY_PROJECT_HERE.github.io'"></meta>
<!-- approach from http://www.backalleycoder.com/2016/05/13/sghpa-the-single-page-app-hack-for-github-pages/ -->
<script>
(function(){
var redirect = sessionStorage.redirect;
delete sessionStorage.redirect;
if (redirect && redirect != location.href) {
history.replaceState(null, null, redirect);
}
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment