github

GitHub Pages

Using the automatic page generator for a repository

  1. Go to the GitHub website
  2. Open your repository
  3. Click Settings
  4. Under GitHub Pages, click “Launch Automatic Page Generator”
  5. Follow the instructions

Using Git to create pages from scratch

  1. Create a new repository or clone an existing one.

  2. 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

  3. 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”

  4. 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

Alex Cican - How I moved my websites to Dropbox and GitHub

Treehouse - Using GitHub Pages To Host Your Website


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow