Welcome to the comprehensive guide on deploying Angular applications to GitHub Pages! š
By the end of this tutorial, you'll learn how to deploy your Angular projects seamlessly to GitHub Pages, making them accessible to the world. Let's dive in! š»
Before we start, make sure you have the following prerequisites in place:
First, let's create a new Angular project:
ng new my-angular-appNavigate into your project directory:
cd my-angular-appTo deploy your Angular app to GitHub Pages, we need to do some configuration.
ng build --prod to build your project in production mode. This command will generate an optimized version of your application in the dist/my-angular-app directory.ng build --prodcd dist/my-angular-app
git init
git add .
git commit -m "Initial commit"git remote add origin https://github.com/yourusername/my-angular-app.git
git push -u origin masterGo to your GitHub repository and navigate to the Settings tab.
On the left sidebar, click on Pages. If you don't see the Pages option, follow these steps to enable GitHub Pages.
Under Source, select gh-pages branch or master branch deployment, depending on your preference. The gh-pages branch will be created automatically when you push your built project to the repository.
Click Save and your GitHub Pages URL will be displayed.
Now, navigate to the URL provided in the GitHub Pages settings and check if your Angular application is deployed successfully.
š Note: If you face issues with the initial deployment, delete the .git folder from your project directory and push it again to GitHub.
To deploy your Angular application to a custom domain, you'll need to follow the steps outlined in these instructions.
Which command builds an Angular project in production mode?
Happy coding! š