How to add custom domain to your jekyll blog (provided that you built your site using github pages).

jekyll logo here

If you are using github pages to set up your jekyll site, chances are github will provide you a default URL that looks something like this:

http(s)://<username>.github.io/<projectname>

For example, I have a git-repo that is called: myblog, so the URL github assigned me is going to be:

http(s)://zhouxiang19910319.github.io/myblog


So what should you do if you want to use your own domain instead of the default one?


Step 1: Configuring A records with your DNS provider

  1. Edit A records using your domain hosting site.

DNS Zone Editor

You should create A records that point your custom domain to the following IP addresses: original article

  1. Add in one CNAME record for your custom domain. After everything is done it should looks something like this:

Zone File Records

Step 2: Create CNAME file in your github repo.

Under your github repo, click on create new file, name the file as CNAME. At the first line of the file, add in your custom domain name, for example, if my site’s domain name is: xyz.com, then add that to the first line of the file then commit.

Step 3: Edit your _config.yml file in your project folder.

Go to your site folder, open _config.yml delete the line: baseurl: and add your own domain under url, in the format of:

url: "https://xyz.com"

Now if you refresh your github repo, under settings=>githubpages, you can see your site is published at https://xyz.com. Do notice that there might be a few minutes of delay before your site is successfully be linked to the domain, so be patient.


Follow me on Twitter, on GitHub and check out my website slowpacedcoding.com for more articles like this.