Hosting a website on GitHub with a custom domain is a straightforward process.
Here's how to host a website on GitHub Pages with a custom domain:
1. Prepare your website:
Create your website files using HTML, CSS, and JavaScript.
Ensure you have an `index.html` file as the main page for your website.
2. Create a GitHub repository:
Sign in to your GitHub account and create a new repository.
Push your website files to the repository.
3. Enable GitHub Pages:
Go to your repository's settings.
Under "GitHub Pages", select the branch from where you want to publish your website (usually the `main` branch).
GitHub Pages will automatically create a live version of your website at a URL like `username.github.io`.
4. Obtain a custom domain:
You can purchase a custom domain name from a domain registrar like Google Domains, Namecheap, or GoDaddy.
5. Configure DNS records:
Log in to your domain registrar's control panel and navigate to the DNS management section.
You need to create a CNAME record pointing your domain to GitHub Pages.
The exact steps might differ depending on your registrar, but you'll typically enter your custom domain name and set the CNAME target to `username.github.io` (replacing `username` with your GitHub username).
6. Verify the custom domain on GitHub:
Go back to your repository's settings in GitHub.
Under "GitHub Pages" > "Custom domain", enter your full custom domain name.
Click "Save". GitHub will verify ownership of the domain and activate it for your website.
Once the DNS changes have propagated, you should be able to access your website using your custom domain.
Post a Comment