How to Create Your Own Website with GitHub Pages
In one of the pastnotesI talked about the interesting gifts you can give with a domain. One of them is your own website. You don't always have the energy or desire to set up hosting, so if you need a simple static site or blog with good templates, I recommend tryingGitHub Pages.
To get started, register on the websitehttp://github.comIt's free. To make working with your future website more convenient, install the app.GitHub for Mac or GitHub for WindowsIf you know how to work with repositories from the terminal, you don't need to install anything.
- Create a repository in your GitHub account namedusername.github.io, where username is your GitHub username (if they don't match, the site won't work).
-
Once you've created a repository, clone it from your account to your computer - it's not as difficult as it sounds :) You'll essentially have a folder on your computer that will store copies of your site's pages.
To do this, click the buttonSet up in Desktop, and the GitHub app will open. It will ask you where and under what name to clone the repository.
- Open your favorite text editor and create a file in the repository folder named index.html with the following content:
<!DOCTYPE html><html>
<body>
<h1>Hello World</h1>
<p>My website on GitHub Pages. It works!</p>
</body>
</html>
Save the file.
- Now you need to push the changes to the server. Open the GitHub app, find your repository, and clickCommit And Sync (or Publish).
- Done. Now go to your website http://username.github.io.
GitHub Pages has its own simple Markdown pages for websites, but you can look for beautiful free templates from other frameworks, for example, forBootstrap.
Your own domain on GitHub Pages
You don't always want to link to your website like http://username.github.io, so I recommend pointing it to a nice personal domain. For startersregister a domain, if you don't have it yet :)
To point your domain to a site on GitHub Pages, you need to specify that domain in a CNAME file in your GitHub repository and configure the DNS records for the domain itself correctly.
Let's do everything in order.
CNAME file in the repository
- Go to your project's repository on GitHub.
- Create a file in the root of the repository called CNAME (name in capital letters).
- Add your domain or subdomain name without the http:// to the first line of the file. For example, blog.example.com or bestblog.co.ua. This file can only contain one domain.
- ClickCommit changesat the bottom of the page.
Now let's check if everything was configured correctly. Go to your repository and click onSettingsin the right panel of the site.
In the sectionGitHub PagesYou should see a line like this:Your site is published at http://blog.example.com.
Setting up DNS records for GitHub Pages on NIC.UA
To point your domain to GitHub Pages, go to your account on NIC.UA in the sectionMy Orders → Name Servers (NS), check the box next to the desired domain and click the buttonChangeIn DNS records*:
- for the main domain typebestblog.co.uacreate with the name “@”, type CNAME and specifyin username.github.io data.(with a period at the end), where username is your GitHub username.
- For a subdomain like blog.example.com, add a CNAME record with the subdomain name (e.g. “blog”) and specify username.github.io in the data.(with a period at the end), where username is your GitHub username.
* If your DNS records already contain an A record with the name you want to point to in the new CNAME DNS record (for example, “@” or “blog”), you must first delete the existing A record.
If your domain is not yet served by NIC.UA name servers, configure it accordingly.instructions.
If you have any additional questions or difficulties with setup, please write to us.in support.