Go to https://www.github.com and create an account:
(If you already have an account, you choose if you want to use it or create a new one for this course).
You can choose any username you like for the account; it doesn’t have to be related to your legal or preferred name, though it can be and often is. Some people choose names related to their name, like me (my Github account is jpolitz). Others choose more abstract or whimsical names for their accounts, just like usernames on any other service. Feel free to do whatever feels right to you, and in any event, you can always change it later.
Once you’ve created your account, we are going to create a new repository on Github. A repository is a folder or directory with an associated history of changes that were made to the files within it. In this sense, a repository on Github has some similarities to a folder in Google Drive; the differences are mainly in the level of control we get in managing that history of changes.
Name the repository cse15l-lab-reports
(in my screenshot it looks like the name is taken because I made it before taking the screenshot; it will be green and OK for you). Leave the other settings as they are, and click “Create Repository” at the bottom.
You should see a screen like this (but with your username):
Click the “Create a new file” link (small, in blue, beneath the “Set up in Desktop” button). Make a new file called index.md
, and put some text in it (whatever you like).
Scroll down to the bottom of the page and click “Commit new file”. You should see a view of your repository that now lists a file called index.md
.
You have a public Github repository with some text in it! You can copy the link from your browser and send it to your friends and family to view!
Next, click on “Settings” at the top of your repository, and then choose the “Pages” option in the sidebar:
Choose main
as the source for Github Pages, and click “Save”.
At the top it’ll say “GitHub Pages source saved”. Wait a bit and refresh the page. Eventually you’ll see a message that says “Your site is live at <url here>
.” (This can take a few minutes!) Click the link that’s shown there; at first it will say the page isn’t found. Wait a few minutes, then refresh the page. Then you should see the text you wrote show up on a page like this:
Note that in addition to seeing your file at, e.g, https://jpolitz.github.io/cse-15l-lab-report/, you can also see it with index.html
added to the end of the URL: https://jpolitz.github.io/cse-15l-lab-report/index.html (Try it!). Add another file to your repository with any name you choose, but end it in the extension .md
. Can you use this idea to see that file?
The .md
extension stands for “Markdown,” which is a particular text format used for writing. There are many good documents on the web. A good cheat sheet and explainer are here:
Skim both of those documents, then try to use some of the elements described in the cheat sheet in your index.md
file. How do some of the different formatting options show up when you use them? Are any surprising?
You should now have:
index.md
and another one you made up)Congratulations – you now know how to make a (simple), public-facing website with basic formatting! You can share the link to your page with anyone in the world with an internet connection, and they can see your page.
(Fun fact: the page you are reading is written in Markdown and uses Github Pages!)
So far, we’ve suggested that you make all your edits in your web browser using Github’s tools for creating new files and editing existing ones. However, this is a remarkably inefficient workflow, because each edit can take a few minutes to show up. Much better would be to use an offline tool, like Visual Studio Code or another editor, that can give better quick feedback as you work.
To edit offline, we need to be able to (a) download the repository to our computer, (b) edit the files, and (c) upload the changes back to Github. Github will re-render all of the Markdown into nice web pages for us each time we re-upload.
There are many ways to download the code from your repository and upload changes. We will use Github Desktop to do this today, and see other options in the future. Even if you have some other preferred way to do this that you’ve used before, please do follow the tutorial! You may learn something new and useful.
Download the Desktop Client for Github. Install it, and log in with your Github account. The startup page should look something like this:
Then, you can get the code from your repository in one of several ways:
<> Code
button; you can click on that and choose “Open with Github Desktop”You’ll see a message about cloning, and then see this page:
One thing that I often find a little surprising about this page is that it doesn’t list any files – index.md
is nowhere to be found here! This is because Github Desktop (and the underlying tool, git
) are all about tracking and recording changes; we won’t see much in this interface until we make some edits or new files.
If you don’t already have it, go ahead and install Visual Studio Code. It is a powerful and free source-code editor that we will use throughout this class. Features include support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and embedded Git.
A good way to make edits is to use the convenient “Open in Visual Studio Code” button. This will open a VSCode window in the directory you just cloned. If you click it, you should see a fresh window like this:
Here’s where VSCode comes in handy – open one of the files and look in the top right corner of the window. There should be a few little symbols, one that looks like two panels with a magnifying glass over the right panel
Click it, and a live-updating preview of the rendered Markdown will appear!
How cool! Make a few edits here; add some text, try out the live formatting. Then make sure to save the file.
Go back to the Github Desktop window. Now you should see something like this:
This view is called a diff, and it’s showing a summary of what changed. In red, with -
signs next to them, are lines that I removed from the file. In green, with +
signs next to them, are lines that I added to the file. This is for us to review before we do two further steps:
If you’re happy with your updates, click “Commit to main
”. Above that button there’s also a box where you can write a short message for your own bookkeeping about why you made this change; in this case you might write “trying out formatting” or similar.
In this case (unlike in the Github interface in your browser) this commit action only makes changes on your computer’s copy of the repository. If you opened up Github right at this moment you will see that these changes are not shown on Github yet.
A separate step takes our committed changes and pushes them to Github to store them in the remote repository. You’ll see a message prompting you to do this on the right-hand side in Github Desktop:
This message uses the term origin to refer to the remote repository. After clicking this, you can verify that the changes did in fact show up when you view your repository’s code on Github. Shortly, you should also see your web page update with the newly-written or changed text.
For your lab report (see below) there are a few key features we need to make sure we practice.
One important part of setting up lab reports in this class will be including screenshots of your work on the page, which means:
Get your first lab report started by making a new file called lab-report-1-week-0.md
. Then, find an image on your computer, like a screenshot from last week’s lab, maybe, or a new screenshot you take now. Copy or move that image file into your repository that you have open in VScode (you can drag and drop it into the file explorer).
Then, add an image tag (use the Markdown cheat sheet!) to refer to that image in lab-report-1-week-0.md
. Commit the changes to that file along with the image, and push to Github. Verify that you can see the image in the published version of your site.
One thing that’s helpful on pages like yours is to have links between pages. Add a link to the index page of your site that points to your lab report page. Which of the following styles works?
[Lab Report 1](lab-report-1-week-0.html)
[Lab Report 1](https://<your-username>.github.io/<your-lab-reports-repo>/lab-report-1-week-0.html)
Feel free to get creative with your page. Github has free themes you can use.
You can also read more about Jekyll, a tool Github Pages uses to turn your markdown files into web pages.
In general, if you want, feel free to do as much styling, editing, theming, etc as you want with your page – it’s yours!
When you’re done, visit Gradescope and submit to the Week 0 Lab Submission assignment. Finish before class on Wednesday so we’ll be set up for labs (and lab reports!) going forward.