If you store a copy of your website’s source code in a GitHub repository, you can use Netlify to host that site.
Netlify also automatically redeploys your site when you push any new changes to the repository branch that you are hosting.
How to Create a Basic Example Angular App
You can create a simple Angular application using an editor such as Visual Studio Code. You can then host this website using Netlify.
Create a new Angular app. Create a simple home page. Replace the code in the app. component. html file with the following landing page content:
Our Business Website
Our Business Website
Learn how to design, develop, and maintain your professional website in no time.
What We Do
We give you the tools to develop websites and unique solutions for your customers. We also provide training for maintenance and other website related topics.
About Us
We are a small business operating from Melbourne, Australia. Our spaces are uniquely crafted so clients can also visit us in person.
How to Push Your Angular Code to GitHub
You will need to store your code in a remote repository for Netlify to access the source code.
You can create a new repository on GitHub, and push your website’s code to that repository. If you are not familiar with GitHub, it might be useful to understand some of GitHub’s basic features first.
Create a new repository on GitHub.
You can do this by logging in to GitHub and clicking on New.
Enter the details for your new repository.
Give it a name such as “netlify-app”, and a description.
Do not initialize the repository with a README file, .
gitignore file, or license.
In a terminal on your computer, navigate to the directory where you stored your Angular app.
Run the following commands to initialize your folder as a git repository: git initgit add .
git commit -m “first commit” Push the code inside this folder to the new remote repository you made on GitHub.
Follow the git remote add original, git branch, and git push commands provided by GitHub on your remote repository page: git remote add original
How to Use Netlify to Host Your Code
To host your code using Netlify, you will need to give it access to your GitHub source code. Netlify will then use the dist folder of your Angular project to publish the built version of your code.
You can configure all of these settings by following the configuration steps when creating a new site:
Log in or sign up to Netlify.
You can do so using your GitHub credentials.
From the main dashboard and site list page, expand Add new site, and select Import an existing project.
Select GitHub.
Click on Configure Netlify on GitHub.
Click on Install.
Netlify will display a list of your GitHub repositories.
Select the one that you’d like to host.
For example, if you have named your repository “netlify-app”, then select “netlify-app” from the list.
In the configuration screen, leave the Owner, Branch to deploy, and Base directory fields at their default values.
If you were publishing a specific branch, such as a separate “Production” branch, you could add that into the Branch to deploy field.
Change the Build command field to “ng build”.
For the Publish directory field, type dist/
Hosting Your Website Using GitHub and Netlify
Hopefully, you can now successfully host a website using GitHub and Netlify. You can set up automatic deployments to certain branches of a GitHub repository. This way, you can automate and streamline the deployment of your website.
But Netlify isn’t the only way you can deploy an Angular app online. You can also use other platforms such as GitHub Pages.