How to Deploy Angular 2+ Web Apps to Github

Github pages allows you to host static websites and web apps for free using the same workflow you use to host repositories, you just commit and push. You can even associate a custom top level domain name to your website or web app by adding a CNAME file.

In this short guide we'll see how to host an Angular 2+ web application using Github pages. So lets get started.


You need to have Node.js, NPM and Angular CLI installed, you also need to generate a new Angular 2+ project using Angular CLI or you can also apply this to an existing project that you want to deploy to Github pages.

Next you also need to install a package which makes the process of deploying to Github pages easy.

npm install -g angular-cli-ghpages

Building the Angular 2+ app

The next step is to build your web application for production and with the base href location set to your Github page URL.

ng build --prod --base-href "https://<YOUR_GITHUB_USER-NAME><YOUR_REPO_NAME>/"

Deploying to Github pages

Now you are ready to deploy your web app to Github pages. Thanks to angular-cli-ghpages this is a one command process so just run:


You web app will be depoyed to:

comments powered by Disqus