How to link domain and sub-domain with Github Pages

Link Github Pages in two simple setup steps

January 10, 2017 - 2 minute read -
code github

Add CNAME file to Github repository

  • Go to
  • Sign in to your Github account and create repository with the name of “”.
  • For me it is “” as repository name.

  • Create a branch with name “gh-pages”.

  • Now create CNAME file, click “Create new file” button.
  • Enter “CNAME” as filename and “” as content of file and click “Commit new file”.
  • (For sub-domain add in CNAME).

  • Click repository “Settings” from top right corner.
  • In Github pages section, you should see “Your site is ready to be published at “

Login to your domain provider

  • Go to domain manager and domain settings then “Manage DNS”

  • Add new records, click “Add” button.
  • Here you will need to create two records for your domain:
  • Record type “A” with host “@” pointing to

  • Record type “CNAME” with host “www” pointing to (In my case (For sub-domain add “subdomain” in place of “www”).

  • Your Record list should look like something

Thats all, now try to visit your domain you should see your site up and running, enjoy :)

Setup Jekyll for free theme (optional)

  • Download the theme @
  • Open Terminal and type $ wget
  • Unzip it and use it as a regular jekyll folder.
    $ unzip
  • Get inside the newly extracted folder
    $ cd jekyll-cayman-theme-master
  • Get the required gems
    $ bundle install
  • Use it!
    $ jekyll serve
  • For me it look something like

For more details read about Jekyll on its web page.

Fork on Github - stackskull