Github pages allow us to easily deploy websites as long as they don't have any backend. In this article, I'm going to show you how I deploy websites using Github pages.
You can't deploy on Github pages without a repository that contains all your files so make sure you have the repo ready.
Next, you have to install the package gh-pages in your repository.
npm install gh-pages
In the package.json file add this script.
Inside the scripts object in package.json file add the following script.
"publish": "gh-pages -d src"
This script will deploy to Github pages anything in the src directory. You can change src to the name of the directory containing the files you want to deploy.
Next, run the publish script in your command line to deploy to gh-pages.
npm run publish
It may take a bit of time but when it's done you'll see a line that says published.
For your website to be deployed successfully, you'll have to go into the settings of your repository. In the Github pages section change the source branch from master to gh-pages. This branch was created when the publish script was run succesfully.
Once done, go to the url provided and you'll see your live website.