gh-pages
without any history$ git checkout --orphan gh-pages
# ensure you are in the correct directory then,
# remove all files from the old working tree
$ git rm -rf
$ echo "Hello World" > index.html
$ git add index.html
$ git commit -a -m "First pages commit"
$ git push origin gh-pages
You can now load your new Github Pages site at
http(s)://<username>.github.io/<projectname>
You will need a domain name from a registrar.
In the gh-pages
branch of your project repository, or the main branch of your username.github.io
repository, create a CNAME file with the contents www.yourdomain.com
- the canonical domain.
At your registrar's domain configuration page, point your domain to your GitHub website.
Set up two CNAME records (one for the root apex (@) and one for www). Both should point to username.github.io
or username.github.io/repository
.
If your DNS provider does NOT support ALIAS records on the root apex (@), simply create A records that point to 192.30.252.153 and 192.30.252.154.
GitHub instructions for a custom domain
Stack Overflow Q&A: "Custom domain for GitHub project pages"
Audrey Watters - Using GitHub to Power A Web Project: How and Why