4

I'm trying to deploy an Angular app to GitHub pages but setting the gh-pages branch as the source shows the content of the README file.

I've tried the official way which is:

git checkout -b gh-pages
git push origin gh-pages
npm install -g angular-cli-ghpages
ng build --prod --base-href https://[username].github.io/[repo]/

After I run ngh I get this message in terminal:

User@JoseTurron MINGW64 /i/projekt-zaliczeniowy-cdv (gh-pages)
$ ngh
index.html could not be copied to 404.html. This does not look like an angular-cli project?!
(Hint: are you sure that you have setup the directory correctly?)
Diagnostic info: ENOENT: no such file or directory, stat 'I:\projekt-zaliczeniowy-cdv\dist\index.html'
�‍� Uploading via git, please wait...
� Successfully published via angular-cli-ghpages! Have a nice day!

I'm out of ideas on how to solve this. Thanks for any suggestions!

2 Answers 2

4

The solution is as follows:

ng add angular-cli-ghpages
ng deploy --base-href=https://[username].github.io/[repo]/ --name=[username] --email=[email]
Sign up to request clarification or add additional context in comments.

Comments

4

Here is a step-by-step guide on how to deploy the Angular app to GitHub Pages.

  1. git init -- for initializing git, use cmd/shell and hit Enter
  2. git add . -- add all files in git
  3. git commit -m "first commit" -- message for commit
  4. git remote add origin "Your Remote Repository Url" -- connecting to git repo
  5. git push -u origin master -- pushing to git repo
  6. npm install -g angular-cli-pages -- installing Angular pages for deploying and Angular project on GitHub Pages
  7. ng build --prod --base-href="https://Username.github.io/github-Repo/" -- production build ghpages
  8. Go to the project folder after the above steps are completed. There will be a dist folder, go inside dist\>YOurProjectFolder-\> and move all files one level up.
  9. angular-cli-ghpages -- deploying ghpages
  10. Go to the GitHub repo settings, scroll down, there will be GitHub Pages setting, then link your published repo, click on that, and BOOM, the Angular app is live on ghPages.

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.