I’m trying to host my static Angular site on Gitlab Pages, but when I try to navigate to the site, it loads a blank page, which does not happen when I serve it locally. I’m following the instructions on the Angular docs here https://angular.io/start/start-deployment, which says that the static files are located here: dist/my-project-name.
Have you tried downloading the artifacts from the job? That should have just 1 folder named public in it. I’m wondering if your mv command is causing a directory structure that is like public/public whereas GitLab pages is expecting just public
I downloaded the artifacts like you suggested, but the structure looks as intended (artifacts -> public -> assets and rest of my files).
Also just to see if I was doing anything wrong, I tested hosting a simple HTML file (not Angular) which worked fine, indicating my process was right and the bug I’m running into is Angular specific.
Gitlab pages deploys your application to your-username.gitlab.io/your-project/. Angular expects the application to be deployed at root level, which would be your-username.gitlab.io/ and since that’s not where your files would go, we have a problem. We need to adjust our ng build command in out the ci/cd configuration and add a parameter to set the root level of our application.
Here’s a sample yaml file to check out. I think it should work for you. Things to look for:
Replace my-project with your project name.
Adjust node version (e.g. image: node:13.0.1 and @angular/cli version accordingly if needed.