Sep 23rd, 2024
Deploying Static Sites on GitHub Pages
Author: Dhruva SrinivasThis is a rapid guide that goes through deploying static sites on GitHub Pages.
Prerequisites
- A static web site with atleast an
index.html
file - A GitHub repository with said static web site
Step 1 - Add a publishing source
You can configure your GitHub Pages site to publish when changes are pushed to a specific branch, or you can write a GitHub Actions workflow to publish your site.
Literally so easy.
- Navigate to your repository on GitHub
- Under the repository, click on the “Settings” tab
- In the “Code and automation” section of the sidebar, click Pages.
- Under “Build and deployment”, under “Source”, select Deploy from a branch.
- Under “Build and deployment”, use the branch dropdown menu and select a publishing source.
- Save
Step 2 - Magic
- GitHub looks for an
index.html
,index.md
, or aREADME.md
file in your repository as the entry-point for the website - IMPORTANT (but also obvious?) - The files mentioned above MUST be located at the top level of the source folder of the source branch!
- For example, if you configured your publishing source in the
/ (root)
folder on themain
branch, yourindex.html
file should be in/
on the main branch.
- For example, if you configured your publishing source in the
- Go to Settings -> Pages -> Visit Site (under GitHub pages)
- Your static website is now live on the internet!
For detailed documentation: https://docs.github.com/en/pages/getting-started-with-github-pages/creating-a-github-pages-site