CodeBlanks Logo Icon CodeBlanks

Summary - GitHub Pages

Combine the Pages steps to publish a site.

The Pages publishing flow

Publishing a site with GitHub Pages goes through three steps: create the static files, add them to the gh-pages branch, and link the custom domain with CNAME. Each commit updates the site. When this flow is done your site goes live on the web.

echo "merhaba" > index.html
git add index.html
git commit -q -m "site"

Practice Publish the site

Create index.html with merhaba inside and save it quietly. Open the gh-pages branch; create a CNAME file containing the domain www.ornek.com. Add both files and save quietly. Print the contents of CNAME and index.html at the end.

Starter code

terminal
git init -q
# 1) index.html olustur, icine merhaba yaz, ekle ve sessizce kaydet
# 2) gh-pages adinda yeni bir dal ac
# 3) www.ornek.com alan adini CNAME dosyasina yaz
# 4) CNAME ve index.html dosyalarini ekle ve sessizce kaydet
# 5) CNAME ve index.html iceriklerini yazdir

Sample solution

terminal
git init -q
echo "merhaba" > index.html
git add index.html
git commit -q -m "ilk"
git checkout -q -b gh-pages
echo "www.ornek.com" > CNAME
git add CNAME index.html
git commit -q -m "yayin"
cat CNAME
cat index.html

Expected output

www.ornek.com
merhaba

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What is done when publishing a site with GitHub Pages?

  • The files are kept only on the local machine
  • The files are committed on the gh-pages branch Correct answer
  • The repository is created from scratch
  • All branches are deleted

Explanation: When you commit the site files on the gh-pages branch, GitHub Pages publishes those files.

2 Stage the files

Question
git add index.html ____
Answer
git add index.html CNAME

Explanation: Both the CNAME and index.html files must be on the publish branch.

3 Pages summary

Term Meaning
site_content The page contents of the site
root_folder Where publishing begins
publish_flow The order the steps are applied
domain_setup Links a domain to the site

All lessons in Advanced