Skip to content

Setup a website using GitHub Pages

Mikael Roos edited this page Jan 16, 2020 · 1 revision

This is how you can setup your repo to be displayed as a website using GitHub pages.

Precondition

Use your forked course repo on GitHub.

Ensure you have synced your "source" upstream, before you proceed.

About Github Pages

You can publish each repo of GitHub as a website to GitHub Pages. This is an easy way to test HTML, CSS and client side JavaScript.

It is a setting where you choose to publish your repo onto GitHub Pages.

You can use the help as a reference.

Enable Github Pages

Go you your repo on GitHub and select the tab labeled "Settings".

Scroll down to the section on GitHub Pages.

Select the source to be "Master branch". Your whole repo will then be accessible as web pages.

The setting is changed and you will see the url to the website. You need to wait a minute or two, for the website to update itself.

The website is cached and it will always take a minute or two to update itself, even when you later on publish small changes to it.

Add a web page hello.html

Lets try to add a web page in the directory work/s01. Use your texteditor to add it and write some text in it.

Add it to the repo, commit and push your changes. Wait a minut or two.

Open a web browser to your GitHub pages site and add work/s01/hello.html to it and load your newly created page. It should be visible in your web browser.

Add an index page in work/s01

Create an index.html in the directory work/s01 and create two links (<a>) in it. The links should be to your hello.html and try.html.

Publish it and check that the web browser opens the index page when you access work/s01.

Add another index page in the root directory

When you currently open a web browser to the root of you website at GitHub Pages, you will see the content of the README.md. Lets make a index.html to replace that as your home page for the repo.

Your index.html should link to work/s01 so one can reach those pages just by clicking on the links in the web page.

Publish it and check that all links works.

Feel free o add information, images and details to your home page.