Hosting for free with GitHub Pages using Windows (with custom domain)

I am unashamedly cheap. Here is how to host your personal website for no cost on github pages running on a windows platform.

Install a GIT client

There are lots - I chose the one that came up first in a Google search and haven’t tried any others. Download Git For Windows Run Git-2.xx.x-64-bit.exe that you just downloaded and install setting the following options

  1. Use Git from the Windows Command Prompt (default)
  2. Checkout as-is, commit as-is (not default)
  3. Everything else default

Choosing the second item just means you will see less verbose output if you are using a Windows only environment.

Sign up for a GitHub account

  1. Go here https://github.com/ and follow the bouncing ball to create your account, mine is wrish wherever I use wrish replace it with your chosen name.
  2. Choose the free option (obviously).
  3. Verify your email address

Create your website repository

  1. Click Start a Project to create a new repository
  2. Enter the repository name as wrish.github.io ← replace wrish with your username
  3. Click Create Repository

Upload your first bits and pieces

  1. On your Windows workstation with Git installed, open a command prompt
  2. Create your base folder
    md c:\website\www.wrish.com
    cd c:\website\www.wrish.com
  3. Add a robots.txt file (allow search engines to scan) and a CNAME file (replace www.wrish.com with your custom domain)
    echo www.wrish.com > CNAME
    echo User-agent: * > robots.txt
    echo Disallow: >> robots.txt
  4. Here is where you copy your index.html and other files into c:\website\www.wrish.com or just create a placeholder index.html
    echo Hello World > index.html
  5. Init a Git database in the current folder (note if you get an error here, Git4Windows isn’t installed/working)
    git init
    git config --global credential.helper wincred
    git config user.name wrish
  6. Add your first commit (replace wrish with your username)
    git add index.html CNAME robots.txt
    git commit -m "first commit"
    git remote add origin https://github.com/wrish/wrish.github.io.git
    git push -u origin master

At this point you will be prompted for your Git username and password and git should be notified that a new branch called master was created.

Branch master set up to track remote branch master from origin

You can also browse to your website https://wrish.github.io and you should see Hello World or your content.

Create a CNAME to make your website work

  1. If you don’t already have a custom domain, you will need to purchase one
  2. Log into your DNS provider and create a CNAME records (alias) pointing to your Github Website (Don’t use a wildcard alias)
    WWW CNAME wrish.github.io
  3. Test it out! http://www.wrish.com

Ok, so now you have a website, but you need to update it. It involves a few commands that, frankly, I don’t understand, so just create a batch file Publish.bat

cd c:\website\www.wrish.com 
git add * 
git commit -m "Scripted Publish %date%" 
git push origin master 
pause 

Now all it takes is a double click and anything you add to c:\website\www.wrish.com will be uploaded.