Step 1:- Create Repository on github
Note :- Open terminal and goto your project direcoty then run following command which you got after created repository.
Step 2:- git init
Step 3:- git add .
Step 4:- git commit -m "first commit"
Step 5:- git branch -M main
Step 6:- git remote add origin https://github.com/rahuldrupal5788/DevR9angular.git
Step 7:- git push -u origin main
Step 8:- We need to build our code in production mode for that we will create deployment files that will be deployed on GitHub Pages.
By default, this deployment code is generated in the /dist/<ProdectName> folder under the angular project folder, but we need to generate this in the "docs" folder under the angular project folder.
So, we need to make a small change in the angular.json file and change the outputpath value to "docs/".
Step 9:- Run the following command with the baseHref option in the git bash window to generate deployment files in the docs folder.
ng build --prod --baseHref="https://username.github.io/repositoryName/"
Example in my case :- ng build --prod --baseHref="https://rahuldrupal5788.github.io/DevR9angular/"
Note :- Here, username and repositoryName will be your GitHub username and repository name.
Go to your angular project folder and check that the docs folder is created and contains all of the deployment files.
Step 10:- Now commit this folder and push it into the GitHub repository from the following commands in the git bash window.
git add .
git commit -m "upload deployment files"
git push -u origin main
Step 11:- Configure GitHub Repository for publish angular project on GitHub Pages
Now, open the GitHub Pages URL of your deployed angular project in the browser.
Exp :- https://rahuldrupal5788.github.io/DevR9angular/
Comments
Post a Comment