Personal Website Locked GitHub Pages Step by Step Guide

Author

Reads 892

Person in White Long Sleeve Shirt Using Laptop
Credit: pexels.com, Person in White Long Sleeve Shirt Using Laptop

Creating a personal website on GitHub Pages is a great way to share your projects and ideas with the world, but sometimes you might want to restrict access to your site. This is where locking your GitHub Pages site comes in.

To lock your GitHub Pages site, you'll need to create a GitHub account and set up a repository for your site. This can be done in just a few minutes by following the GitHub sign-up process.

The GitHub Pages settings can be found in the repository settings, under the GitHub Pages tab. Here you can choose between a custom domain and a GitHub Pages subdomain.

Readers also liked: Next Js Github Pages

Setting Up Your Site

Setting up your site is a straightforward process. Create a repository on GitHub, which will store your website's source files, and make sure it's public for your personal website. You can give it a clear name like yourusername.github.io, replacing "yourusername" with your actual GitHub username.

Credit: youtube.com, How to Host a Website on GitHub Pages Free (Custom Domain Setup Included)

To create a new repository, log into GitHub and click the "+" icon in the top-right corner, then choose "New repository". Fill in the required details, such as repository name and description, and select the "Public" option to make your repository visible to everyone.

Here's a step-by-step guide to creating a GitHub repository:

Choosing a Username

Your GitHub username will be publicly visible, so choose wisely!

Keep it simple and professional, and make sure it's inoffensive - this represents your personal brand.

Creating a Repository

Creating a repository is the first step in setting up your GitHub Pages site. Log into GitHub and click the "+" icon in the top-right corner to create a new repository. Choose "New repository" and give it a clear name like yourusername.github.io, replacing "yourusername" with your actual GitHub username.

Make sure to set the repository to public, as this is the default setting for a personal website. You can also add a README file to get started, which will create a starter file explaining the project.

Your website files will live in this new repo. Don't forget to make it public, as this is the default setting for a personal website.

Account Setup

Credit: youtube.com, How To Set Up A Login Page And User Accounts For Your Website

To get started with setting up your site, you'll need to create a GitHub account if you don't already have one. This will be the home for your website files.

Head to github.com and sign up for a new account. Verify your email address to ensure your account is secure. Choose an appropriate username that will become part of your site's URL, so make it professional.

For enhanced security, enable two-factor authentication (2FA). 2FA requires you to enter a generated code from an authenticator app or SMS when logging in, proving identity. Using an authenticator app like Authy is more secure than SMS 2FA.

SSH vs HTTPS

When you're setting up your site, you have two choices for authenticating with GitHub: SSH and HTTPS. SSH is more secure, but its setup is more involved.

Setting up SSH requires creating keys, which can be a bit of a hassle. On the other hand, HTTPS has an easy setup process, but it may not be as secure.

Here are the key differences between SSH and HTTPS:

I personally chose SSH for its added security, and I recommend considering it for your own site setup.

Configuring Your Site

Credit: youtube.com, Hosting Personal Website on Github.com(aka Github Pages)

To get your personal website up and running on GitHub Pages, you'll need to create a repository. This can be a new or existing repository, and the name of the repository will dictate your project's default URL.

You'll then need to add your content, including HTML, CSS, and JavaScript files, to the repository. For a personal or team website, these files should be placed in the root of the repository.

To enable GitHub Pages, go to your repository's Pages settings and select the branch and folder to deploy from. GitHub will provide a URL where your site will be published.

Here are the basic steps to configure your site:

  1. Create a repository on GitHub.
  2. Add your content, including HTML, CSS, and JavaScript files, to the repository.
  3. Enable GitHub Pages by going to your repository's Pages settings and selecting the branch and folder to deploy from.

Once you've enabled GitHub Pages, your site will be live at https://yourusername.github.io. It may take a few minutes for your site to be live, so be patient.

Your site's content will live in the repo and automatically publish to the provided URL.

Deploying Your Site

Credit: youtube.com, Host website on github for free in just 2 mins

To deploy your GitHub Pages site, you need to enable GitHub Pages in your repository settings and set the branch and directory.

Any push to your selected branch will automatically deploy the changes, triggering a build and deploy process on GitHub.

Here's a typical workflow: this will make your changes live almost immediately.

You can also use GitHub's official documentation for further reading on GitHub Pages.

To deploy GitHub Pages, you need to enable GitHub Pages in your repository settings and set the branch and directory.

Each commit pushed to the specified branch will automatically trigger a deployment.

GitHub does the heavy lifting by building the site from the static files you push.

You can use a custom GitHub Actions template to deploy your site, as I did in my own project.

Custom Domain Setup

To set up a custom domain for your GitHub Pages site, you'll want to consider using a registrar like GoDaddy, Google Domains, or Namecheap. These options offer affordable .com, .net, and .org choices.

Credit: youtube.com, How to Use a Custom Domain with GitHub Pages

For side projects and personal sites, RecommendedDomains.com is a great option, with domains starting at $9 per year. This can be a cost-effective way to get a custom domain.

To configure your custom domain, you'll need to update your DNS settings with your registrar to point to GitHub's servers. This is a crucial step to ensure your site is accessible at its new custom domain.

Here are some popular domain registrars to consider:

Remember to take care not to enable custom domains on multiple GitHub Pages sites, as this can cause issues. GitHub has documentation on setting up a custom domain, so be sure to check that out for more information.

Troubleshooting

Troubleshooting your GitHub Pages site can be a challenge, but don't worry, I've been there too. GitHub Pages is case-sensitive, so ensure all links and references are correct.

A common issue is encountering a 404 error, which can occur for several reasons. If you recently added a custom domain, ensure your DNS settings are correctly configured and propagated, which can take up to 48 hours.

Credit: youtube.com, Why does my github repo get a 404 error? AKA How to turn on GitHub Pages on a new repository.

If you're using a single-page application (SPA) framework like React or Angular, you'll need to configure your site to redirect all requests to your index.html. To do this, add a 404.html file with a script to redirect to index.html.

Here are some potential causes of 404 errors on GitHub Pages:

  • File paths: Ensure all links and references are correct.
  • Custom domain configuration: Ensure your DNS settings are correctly configured and propagated.
  • SPA routing: Configure your site to redirect all requests to your index.html.

Melba Kovacek

Writer

Melba Kovacek is a seasoned writer with a passion for shedding light on the complexities of modern technology. Her writing career spans a diverse range of topics, with a focus on exploring the intricacies of cloud services and their impact on users. With a keen eye for detail and a knack for simplifying complex concepts, Melba has established herself as a trusted voice in the tech journalism community.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.