Deployment of Angular Application using GitHub Pages

Hello Readers,

In this Article, You will learn how to deploy your Angular Application and Host it on GitHub Pages. So are guys exited to host your first Angular Application on live server!!!

There are certain ways to host your angular application but I am using angular-cli to build Angular application.  To generate the build using angular-cli is as easy as writing one command line statement.

ng build – -prod

Or creating a production build with Ahed-Of-Time compilation is also just as simple.

ng build – -prod – -aot

It will generate the compiled and bundled minified code in a dist/ subdirectory which we deploy and host on GitHub Pages.

Isn’t it awesome guys by simply writing one command line statement will generate build for you? Cheers to Angular CLI Team!!! And Believe me hosting your Angular Applications is also as easy as creating the build. Let’s see how!!!

GitHub Pages:

GitHub has the feature that code hosted on GitHub will be automatically available to GitHub Pages. Before starting with hosting on GitHub You will required account on GitHub and also install the git command line ( ). Now you can host your Angular application using git command line. I will divide the hosting process in following steps

Create the build

ng build – -prod                       or   ng build – -prod – -aot

Remove Dist Directory from .gitignore

By default  dist directory is in .gitignore file so it will not upload it on github server. So when we want dist directory to upload on github server we must remove it from .gitignore file.

Screenshot (179)Screenshot (180)

Create the Repository

  • Go to
  • Create the new repository and name it as shown below

Example :

Screenshot (181)

Copy Remote Server URL

It will be required when we will upload the dist folder.

Screenshot (184).png

Now Open the Command Prompt and navigate to source directory and follow the steps

  • git remote add origin CopiedURLSketch1.png
  • git add .Sketch2.png
  • git commit –m “ready”Screenshot (187).png
  • git subtree push – – prefix dist origin masterScreenshot (188).png

All done now your Angular application is live on URL,

example :


CLI has changed everything. Now we can upload the application to live server with single command line statement. Isn’t it awesome??

Hope this Article will be helpful to you for hosting your Angular application.

2 thoughts on “Deployment of Angular Application using GitHub Pages

  1. This tutorial is great. I like the idea of push dist folder to master branch. But how would you then keep track of dev code i.e. the src folder? How should source code be pushed


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s