GitHub Pages
Using the automatic page generator for a repository
- Go to the GitHub website
- Open your repository
- Click Settings
- Under GitHub Pages, click “Launch Automatic Page Generator”
- Follow the instructions
Using Git to create pages from scratch
-
Create a new repository or clone an existing one.
-
Create a new branch called
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
-
Add an index.html file to the root of the repository.
$ echo “Hello World” > index.html $ git add index.html $ git commit -a -m “First pages commit”
-
Push to Github.
$ git push origin gh-pages
You can now load your new Github Pages site at
http(s)://<username>.github.io/<projectname>
Creating a custom URL for your GitHub page
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.
Resources
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