GitHub is not only a great place to store and share your code with others but they also offer free web hosting of your HTML, CSS, and JavaScript projects!
Github is a web-based platform used for cloud-based Git repository hosting services. GitHub eases the process of working with teams and makes it easy to collaborate on projects. Basically, it is a place where you share and store your stuff and host your HTML, CSS, and javascript projects.
GitHub Pages is a static site hosting service that takes HTML, CSS, and JavaScript files straight from a repository on GitHub, optionally runs the files through a build process, and publishes a website.
Steps to host your site on GitHub:
Create a GitHub account on github.com
The most important step. Github Site
Create New Repository:
-After signing up click on create a new repository.
Then name that repository, remember that your web URL will have the same name as of your repository name and choose who can see your repository (public and private). Then check the box Initialize this repository with README.
After creating the repository:
-Select branch and create a gh-pages branch.
After that prepare your files that you want to upload and rename your main HTML page as index.html. Now click on upload files and select your files. Also, remember to commit a message that describes what you are uploading. Then click on commit changes.
Change some settings:
At repository pages, click on settings and scroll down to the Github pages section. Change none to gh-pages branch by clicking on dropdown and click on save changes. And then you will see the link of your site.
It can take as long as 48 hours for your domain to resolve to your GitHub page. However, it is usually pretty quick, so check back in an hour or so.
Congrats! You’re all set! You now know how to:
- Create a new GitHub repository
- Commit files to said repository, and
- Push files up to GitHub!
From here you can see your files are on GitHub and you can view your project in the browser!
Whenever you want to make changes to your website, you just need to commit the changes and then push the files up to your GitHub repository. Your changes will be published automatically!
That’s it. You have just uploaded your site on GitHub. You can share the link of your site to your peers, if you have made it public.