Introduction to GitHub

Topics: github; gh-pages; README; Markdown; HTML

This section introduces the GitHub web interface, walks through creating a repository, and covers the basics of Markdown and HTML. These topics are important for understanding the basic building blocks of websites and learning how to work with files on GitHub.


Git, GitHub, & GitHub Pages

Before we get started, let’s clarify some terms:

Git is a popular free, distributed version control system–i.e. a piece of software used to track the history of changes in a folder of files. Git can be used on your personal computer, or by online services to track the development of a project, such as…

GitHub, a popular web platform for hosting Git repositories–i.e. a place to store and sync your project files online. Think of it as Google Drive for code with super robust “track changes” baked in. Built around the powerful version control of Git, it provides a handy web interface for managing, editing, and collaborating on repositories.

Originally designed to manage large open-source software projects, GitHub’s use has expanded to many other types of organizations and individuals, with over 40 million users. GitHub provides a bunch of built in project management features including…

Octojekyll logo

GitHub Pages, free static web hosting service available as part of every repository–this means with the click of a button you can fire up a new website!

Intended to host relatively simple sites for your GitHub portfolio or project documentation, GitHub Pages is an ideal solution for creating an open educational resource or personal site to highlight your academic work. Because hosting through gh-pages is free and builds valuable transferable skills, this is a great option for teaching and learning. Users have the opportunity to become creators and participants in global digital culture, developing critical digital literacy about the fabric of the web.

Many organizations and individuals are using GitHub to collaboratively create and publish public websites. For example, Programming Historian, The Carpentries, or this site!


GitHub Practice

Let’s create a new repository, then write some Markdown and HTML to see how gh-pages works.

Create a New Repository

Take a minute to explore your new repository. It currently contains one file, README.md that was automatically added. Check out the “Issues” tab, a great feature for starting conversations and tracking tasks related to the repository.

Activate GitHub Pages

README, Markdown, and Editing Intro

You will notice that by default the contents of the README.md file are displayed on the home page of your repository. This is a convention used in many code projects–README is a place to write the basics about your repository so users will understand what it contains, who made it, and any other information they should know. On GitHub READMEs are usually written in Markdown (thus the .md extension).

Markdown is a standard to simplify writing content for the web designed to be easy to read and write. GitHub Markdown Flavor can be used any where on GitHub to format your writing in comments, Issues, and .md files. The basics are intuitive, much like formatting a plain text email, as can be seen in the Mastering Markdown Guide.

Edit your README using Markdown:

# Heading One

## Heading Two

### Heading Three, etc.

Any text with no empty lines between will become a paragraph.
Leave an blank line between headings and paragraphs.
Font can be *Italic* or **Bold**.
Code can be highlighted with `backticks`.

Hyperlinks look like this [GitHub Help](https://help.github.com/).

A bullet list is created using `*`, `+`, or `-`, like:

- dog
- cat
- muffin

A numbered list is created using a number + `.`, like:

1. one
2. two
6. three
2. four

Once you commit, you will immediately see your README’s updated content rendered on the page. Behind the scenes GitHub is converting your Markdown code into HTML for display.

HTML, Index.html, and Create File Intro

Most of the Web is made up of HTML, CSS, and JS:

When you access a website, the server sends your computer the code which your browser renders into a web page that you can view and interact with. Thus, one fascinating aspect of the web is that everyone must share code to participate.

To review the basic building blocks of the web, next let’s create an HTML file. We will start with an index.html file because by default the server provides index as the home page of your site.

<!DOCTYPE html>
<html>
    <head>
        <title>Example Title - appears in browser tab</title>
    </head>
    <body>
        <h1>Header One: Big Text</h1>
        <p>An example paragraph.</p>
        <h2>Header Two</h2>
        <p>Paragraph with <strong>Bold text</strong>.</p>
        <p>A link to <a href="https://github.com">GitHub</a>.</p>
    </body>
</html>

After you commit, you will be redirected to your repo home page. Clicking on the word “commits” in the upper right of the file box will bring you to the history of your repository. Each commit is represented on the page displaying your commit messages. Clicking on the hash (the series of numbers to the right of the commit message) will display all the information about the commit, including all the changes made to files.

Now that we have an index.html, let’s visit our new website. The URL for any GitHub Pages site follows the pattern:

https://username.github.io/repositoryname/

You can also find the link by looking back in your Settings once gh-pages has been activated.

Each time you make a commit GitHub Pages will re-deploy your files, which might take a minute. Once it is complete (assuming everything goes well!), a green check will appear next to your commit in the history.