PUT YOUR WEBSITE ONLINE
Put your website online with GitHub Pages
Publish a static website on GitHub Pages, then optionally connect your own domain.
This guide uses GitHub Pages to publish a static website. Start with its default address, then connect your own domain if you want one. Everything below can be done in your browser.
For static HTML, CSS, and JavaScript websites. Apps that need a server, database, or secret API key need a different hosting setup.
Before you start
- A working website folder with index.html, CSS, JavaScript, and images. Extract any ZIP first.
- A GitHub account with a verified email. Uploaded files will be public: leave out passwords and API keys.
- Optional: your own domain and access to its DNS settings. Domain registration and renewal cost extra.
Use a free GitHub Pages address
Use this path first. Your address will look like https://USERNAME.github.io/my-site/.
Check your folder
Put index.html at the top level of the website folder, beside its CSS, JavaScript, and image files or folders.
Upload to GitHub
Choose New repository → name it my-site → Public → Add a README → Create. Then Add file → Upload files: upload the website folder’s contents and Commit changes. index.html should appear beside README.md.
Turn on Pages
Open the repository’s Settings → Pages. Select Deploy from a branch → main → /(root) → Save. If your branch has another name, select that branch.
Open and share
Allow up to 10 minutes, then choose Visit site in Pages. Check the page and its links. Share the address shown, such as https://USERNAME.github.io/my-site/.
Your website opens at its github.io address. Share this website link, not the github.com repository link.
Connect your own domain
After the free address works, add a www address such as www.example.com. DNS settings tell the domain where to find your website.
Save the domain in Pages
In Settings → Pages → Custom domain, enter your own www.example.com and Save before changing DNS. Leave out https:// and any page path.
Add one DNS record
At your DNS provider, set Type = CNAME, Name = www, Value = USERNAME.github.io. Replace USERNAME with the repository owner’s GitHub username. Do not include my-site or https://. Use a www address you are ready to move.
Wait for the connection
Check the domain status in Pages. DNS changes and HTTPS availability can each take up to 24 hours; follow the status shown there.
Turn on HTTPS and check
Select Enforce HTTPS when available. Open your https://www.example.com and check it. This connects www only; example.com without www needs separate DNS setup.
Your chosen www address opens the website over HTTPS.
Check your published site
- The public website address opens and the page's styling and links work.
- The repository contains only files intended for public access.
- If you connected a domain, its www address works over HTTPS.
Optional help & next steps
Recommended before connecting a domain: verify ownership
GitHub recommends verifying your domain before adding it to a repository. This helps prevent another GitHub account from using it. It is a recommended protection, rather than a required step for basic publication.
In your GitHub account settings, open Pages → Add a domain. Follow the displayed instructions to add GitHub's generated TXT record at your DNS provider, then choose Verify in GitHub. These are account settings, separate from the repository's Pages settings. Keep the TXT record after verification. See Verify a custom domain in the sources below for the exact record format.
If the website or domain does not work
| Check | What to do or expect |
|---|---|
| The website shows a 404 or the wrong page | Check that index.html is at the top of the selected branch and /(root) folder. Use the Visit site link in Pages, allow publication to finish, and inspect the deployment status in the repository's Actions tab if it fails. |
| The page opens without styling or images | Check that all required files were uploaded and that filenames match exactly, including capitalization. For a project address such as /my-site/, use matching relative asset links such as ./styles.css rather than /styles.css. Ask your coding tool to correct the paths if needed. |
| The custom domain or HTTPS remains pending | Check that the www CNAME points to the repository owner's USERNAME.github.io, without a repository name. Check the DNS provider's instructions if an existing record conflicts. Allow DNS and certificate setup time, then review the status and error shown in Pages. |
| www works, but the bare domain does not | This short path configures only www. Follow GitHub's custom-domain documentation to configure the apex domain as well; do not put a normal www CNAME at the bare domain without checking the provider's supported method. |
When you update the website later
Upload and commit the changed website files to the same publishing branch; GitHub Pages deploys changes from that branch. Keep the folder structure and asset paths intact.
When you save a custom domain with branch publishing, GitHub creates a CNAME file in the repository. Keep that file when replacing your website files so later updates retain the domain setting.
Sources, cost & review notes
Based on official GitHub documentation checked on November 2, 2026; no account setup, public deployment, or DNS change was performed for this guide.
GitHub Pages is available for public repositories on GitHub Free, including the default github.io address. Registering and renewing your own domain is a separate cost.
- GitHub Pages: what it hosts and plan availability (opens a new tab) (reviewed 2026-11-02)
- Create a GitHub Pages site (opens a new tab) (reviewed 2026-11-02)
- Upload files to a repository (opens a new tab) (reviewed 2026-11-02)
- Configure the publishing branch and folder (opens a new tab) (reviewed 2026-11-02)
- Manage a custom domain (opens a new tab) (reviewed 2026-11-02)
- Verify a custom domain (opens a new tab) (reviewed 2026-11-02)
- Secure GitHub Pages with HTTPS (opens a new tab) (reviewed 2026-11-02)