Last Updated: September 09, 2019
· clkao

angularjs html5Mode on github pages

angularjs provides html5Mode, which makes your app use pushstate-based URL instead of hashtags. However this requires server side support, since the generated urls need to be rendered properly as well.

This actually works fine with github pages' custom 404 pages, though it's only available for custom domain enabled pages.

Simply copy index.html to 404.html, and add this to your app:

angular.module('app', []).config(function($locationProvider) {

Note that if you are on angular 1.1.5, make sure you set <base href="/"> for html5Mode to work properly.

2 Responses
Add your response

So you're saying that if my repo uses a <username><repo> URL I'm out of luck?

over 1 year ago ·

But does the server response status say 404? If so, that's not good.

over 1 year ago ·