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
- Use Git from the Windows Command Prompt (default)
- Checkout as-is, commit as-is (not default)
- 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
- 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.
- Choose the free option (obviously).
- Verify your email address
Create your website repository
- Click Start a Project to create a new repository
- Enter the repository name as wrish.github.io ← replace wrish with your username
- Click Create Repository
Upload your first bits and pieces
- On your Windows workstation with Git installed, open a command prompt
- Create your base folder
md c:\website\www.wrish.com
cd c:\website\www.wrish.com
- Add a
robots.txt
file (allow search engines to scan) and aCNAME
file (replace www.wrish.com with your custom domain)
echo www.wrish.com > CNAME
echo User-agent: * > robots.txt
echo Disallow: >> robots.txt
- Here is where you copy your
index.html
and other files intoc:\website\www.wrish.com
or just create a placeholder index.html
echo Hello World > index.html
- 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
- 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.
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
- If you don’t already have a custom domain, you will need to purchase one
- 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
- 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.