Creating websites with GitHub Pages
You can create static websites that will be hosted by github, and automatically updated whenever you push changes to your content on git.
References:
The page you are now reading is a Tufts summary. The original full GitHub documentation starts here:
About GitHub Pages - GitHub Enterprise Cloud Docs
Getting Started:
To get started, browse to the GitHub Tufts University Organization
Ensure you are logged in. (It should say “You are logged in.”)Go to
Repositories
>New Repository
Owner: Tufts University
Repository name: the name of your site, for example,
testwebsite.it.tufts.edu
Visibility: Internal (notice, this is the visibility of the repo, not the website. You will set the visibility of the website momentarily in the next step, below)
Yes, add README
After the repository is created to go
Settings
>Pages
Visibility: Public (notice, this is the visibility of the website, not the repo it came from. If you set it to Private, users will be prompted for username/password and Tufts Duo before they can see the website. If set to Public, the entire Internet will have access)
Source: Deploy from a branch
Select the branch: Main, and the path
/ (root)
Save.
After clicking Save, a new field will appear that allows you to specify Custom Domain. Enter the name you want, for example
testwebsite.it.tufts.edu
For more info, see Configuring a custom domain for your GitHub Pages site - GitHub Docs
Entering the custom domain into the field above actually creates a file called
CNAME
in your repo. You can edit this file to change the custom name if you want. If you use an apex domain such asexample.com
, you will automatically getwww.example.com
supported as well. You may only have one name in yourCNAME
file. If you need to support more than one name, you need to use a redirector. Redirection is supported by most domain registrars, and at Tufts we support it via lb-redirector-tss.it.tufts.edu.Configuring DNS:
If your custom name is not an apex domain (for example, your custom name is
testwebsite.it.tufts.edu
) create a CNAME to whatever organization or username your repository is under:tufts-technology-services.github.io
tufts-university.github.io
youruserprofile.github.io
if the repository is not in one of the above organizations
If your name is an apex domain, for example,
foobar.org
, follow the instructions Managing a custom domain for your GitHub Pages site - GitHub Docs to find what IP addresses you should point your DNS to. CreateA
records forfoobar.org
and create CNAME record forwww.foobar.org
going go@
which is a reference to the apex domain. In other words, create these:foobar.org A 185.199.108.153
foobar.org A 185.199.109.153
foobar.org A 185.199.110.153
foobar.org A 185.199.111.153
www.foobar.org CNAME @
You might need to refresh the
Settings
>Pages
page, to get the “DNS Check” check near the bottom. After your DNS changes have propagated, you should get “DNS Check Passed” at the bottom. Then you can click the checkmark to force HTTPS. Github will automatically manage SSL certs via letsencrypt.
If your repository contains
index.html
,index.md
, orREADME.md
, that file will be served by default when the URL requested by clients does not contain a filename. Markdownmd
files are automatically rendered to HTML.Optionally, much more powerful style and formatting can be obtained by using the Static Site Generator (SSG) Jekyll. For more information, see GitHub Pages and Jekyll. To see themes examples, you have to jump through a couple of hoops. First go to Supported themes, then click on a theme, and it will take you to the source code of that theme, but notice over in the right, there is a link to a
github.io
page. Click that link to see an example of the theme. Here are a few examples:For more, go to Supported themes, and follow the links as described above