Welcome to the ninth blog of the series! In the last blog, we created our first website with GitHub Pages. It was deployed on the domain .github.io, but did you know that you can use a custom domain name for your GitHub Pages site? In addition, you can secure your website with SSL (Secure Sockets Layer) to ensure a safe and encrypted connection. In this blog post, we will explore how to set up a custom domain and enable SSL for your GitHub Pages site.
Prerequisites
Before we begin, make sure you have the following:
-
A GitHub account. You can create one for free at github.com.
-
A registered domain name from a domain registrar (e.g., Namecheap, GoDaddy).
Setting Up a Custom Domain
To use a custom domain name for your GitHub Pages site, follow these steps:
GitHub Pages: Custom Domains and SSL GitHub Pages provide a convenient way to host your static websites, but did you know that you can use a custom domain name for your GitHub Pages site? In addition, you can secure your website with SSL (Secure Sockets Layer) to ensure a safe and encrypted connection. In this blog post, we will explore how to set up a custom domain and enable SSL for your GitHub Pages site.
Prerequisites
Before we begin, make sure you have the following:
-
A GitHub account. You can create one for free at github.com.
-
A registered domain name from a domain registrar (e.g., Namecheap, GoDaddy).
To register your domain you can use the free domain TLDs available from the GitHub Student Developer Pack. For more information, you can refer to the blog below.
https://dev.to/pratik_kale/github-student-developer-pack-overview-1jld
Setting Up a Custom Domain
To use a custom domain name for your GitHub Pages site, follow these steps:
-
Log in to your domain registrar's website and locate the DNS management settings for your domain.
-
Add a CNAME record for your custom domain. The CNAME value should be
<your-username>.github.io
, where<your-username>
is your GitHub username. -
Save the DNS changes and wait for the DNS propagation to take effect. This may take some time, usually up to 24 hours.
Once the DNS changes have propagated, you can proceed with configuring your GitHub repository to use the custom domain.
-
Go to your GitHub repository's page.
-
Click on the "Settings" tab.
-
Scroll down to the "GitHub Pages" section.
-
In the "Custom domain" field, enter your custom domain name (e.g., www.yourdomain.com).
-
Click on the "Save" button.
GitHub Pages will automatically configure the necessary settings to associate your custom domain with your repository. You can now access your GitHub Pages site using your custom domain.
Enabling SSL for Custom Domains
Enabling SSL (Secure Sockets Layer) for your custom domain ensures that your website is accessed securely over HTTPS. To enable SSL for your GitHub Pages site, you can use a service like Cloudflare or GitHub's Automated Certificate Management (ACM).
Using Cloudflare for SSL
-
Sign up for a Cloudflare account.
-
Add your custom domain to Cloudflare and follow their instructions to set up your DNS.
-
Once your custom domain is set up on Cloudflare, go to the "SSL/TLS" section.
-
Choose the SSL/TLS encryption mode to "Full" or "Full (Strict)".
-
Cloudflare will automatically provide an SSL certificate for your domain.
Using GitHub's Automated Certificate Management (ACM)
GitHub's ACM provides a simple way to enable SSL for your custom domain directly through your GitHub repository settings. Here's how to enable it:
-
Go to your GitHub repository's page.
-
Click on the "Settings" tab.
-
Scroll down to the "GitHub Pages" section.
-
In the "Custom domain" field, enter your custom domain name (e.g., www.yourdomain.com).
-
Click on the "Enforce HTTPS" checkbox.
GitHub will automatically generate and manage an SSL certificate for your custom domain, allowing your site to be accessed securely over HTTPS.
Verifying SSL
To verify that SSL is enabled for your custom domain, you can visit your website using the HTTPS protocol. For example, enter https://www.yourdomain.com in your web browser. If the website loads without any security warnings, SSL is successfully enabled.
Conclusion
Setting up a custom domain and enabling SSL for your GitHub Pages site can significantly enhance its professional appearance and security. By following the steps outlined in this blog post, you can easily configure your custom domain and ensure secure access to your website. Whether you're showcasing a personal portfolio or hosting a project website, custom domains, and SSL provide a seamless and secure experience for your visitors. Start leveraging the power of custom domains and SSL with GitHub Pages and elevate your online presence!
Thank you for reading and do let me know your thoughts in the comments!
Connect With Me: Website | Twitter | LinkedIn | Instagram | Mail