Integrate GitHub-Pages in Angular 6 App

2 minute read

What is GhPages

Do you want to save time to create post or article while writing software code ? Or do you want to see your angular app live running in the internet without deploying it separably on azure or AWS ? Then GhPages or Github Pages is the answer to that.

I have one github project written in angular and I run my app live in github itself by using ghpages In this article, I will walk you through the process of publishing your app into ghpages.

What GhPages Can Do

GhPages host file on github server and give you unique URL to view as website. 

When we create Angular project using Angular CLI, it creates project files along with the file. We write description about the code and how to get the code from github, how to install node packages and how to run etc. All of this steps are well documented in file. Sometimes I personally put some more examples about my shared directive or services. Github can host this file in website with various themes and you can see your document live in website.

GhPages can also host your Angular App and give you unique URL to view your live app running on github server

Yes, you can see your angular app live running with the help of ghpages. Once you check-in your dist folder to your github repository then ghpages can host the entire dist folder and you can see your app running.

How do I integrate in my Angular 6 app

In order to integrate in ghpages in your angular app please follow the below steps

Now you can run your publish script (npm run publish ) whenever you want to deploy your file to github pages.

build:prd will build the project in prod mode so that it will create a dist folder where the bundle files and file will be placed.

deploy:gh will deploy the dist folder into github pages.

Example hosting Angular App on GithubPages

Please visit my e-Store app on GitHub and see how my project is live working on github server. Also don't forget to add some item in your cart on my online website for e-store hosted on ghpages.

Here are the steps, to follow in order to host dist folder on ghpages.

  1. Go to github repositoy then
  2. Select settings scroll to GitHub Pages section and
  3. Select `​gh-pages branch` from the drop down list

GitHub Pages Settings to host dist folder

Example hosting on GithubPages

please checkout my Webpack Typescript Library Consumption Sample 

In this repository I do not have any web application however I had my file that I wanted to publish as website and you cant believe using ghpages themes it is just looking like a WordPress post. Please check out my online ghpage website for ​​   ``   file.

Here are the steps you will do in order to setup ghpages so that it will host your file

  1. Go to github repositoy then
  2. Select settings scroll to GitHub Pages section and
  3. Select `​master branch` from the drop down list
  4. Also You can select your favorite them. (optional)

[caption id="attachment_495" align="alignnone" width="1576"]GitHub Pages Settings For Master Branch GitHub Pages Settings for hosting file[/caption]