1

How to deploy angular 2 website application on github? I am new to Git and github so just saw the basics on internet and created a repository on github and finally a url was generated in my git bash after running all steps and when I tried to open it Github 404 error pages was showing.

These are the commands which I ran through :

git remote add origin https://github.com/Muraliduke/MuraliDukeResume.git

git push -u origin master

ng github-pages:deploy

Is there any difficulty for single page application to host a website on github? I tried with normal html content and my website on github works fine. But this with ng2 is not working. Just saw on internet that there must be some prefix to be done to support SPA on github but since I am not familiar with github didn't understand it. So kindly suggest me a solution ?

1
  • What tutorial are you following ? Commented Jun 4, 2017 at 18:11

2 Answers 2

1

There are a few things :

  • Deploying to GitHub pages using Angular CLI has been deprecated. Use angular-cli-ghpages
  • Add the 404.html fix
  • Ensure you have "turned on" GitHub pages for your gh-pages branch from the repository settings
  • optionally, add custom domain

This blog has everything you need.

Sign up to request clarification or add additional context in comments.

Comments

0

Make sure to do a build to get the necessary files into dist .

ng build --prod

First get all relevant the files from the Dist Folder of your application

for me it was the css files in the assets folder main.bundle.js polyfills.bundle.js vendor.bundle.js

Then push this files in the repo which you have created.

1 -- If you want the application to run on the root directory - create a special repo with the name [yourgithubusername].github.io and opush these files in the master branch

2 -- Where as if you want to create these page in the sub directory of in a different brach other than than the root , create a branch gh-pages and push these files in that branch.

In both the cases the way we access these deployed pages will be different .

For the First Case it will be https://[yourgithubusername].github.io and for the second case it will be [yourgithubusername].github.io/[Repo name].

If Suppose you want to deploy it using the second case make sure to change the base url pf the index.html file in the dist as all the route mappings depend on the path you give and it should be set to [/branchname].

Github Repository - https://github.com/rahulrsingh09/Deployment

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.