Originally written here on the DEV.to website.
- Unity WebGL Build
- GitHub account for GitHub Pages (yes we will be hosting the game using GitHub pages)
Step 2- In the Build Settings -
- Add all your game scenes.
- In the platform section: Choose WebGL > Switch Platform (this step is necessary when you are using WebGL for the first time) It will take sometime to convert your game's platform.
- After this Click on > Player Settings... and do the necessary changes for your game like - Product Name, Game's Resolution, adding/removing Splash Screen etc.
- Click > Build and you are good to go. It will ask you where to put your game files and create a "WebGL Build folder" for you.
Step 2 - Now Click on Settings > Go to the bottom of the page where you can see "GitHub Pages"
Step 3 - Now you need to provide a source to GitHub for hosting your game as a GitHub Page. To do so, below Source Click on None > Choose "main" branch (the branch where you have committed your files).
So there you have it !! An easy way to host your Unity based games on the web for free, for you and your friends to play. This option opens to many possibilities which you can try like - making your games more accessible, testing your games before the final release, adding them to your online portfolio etc.