Upload a Website to GitHub Pages
Tags: webdev, git, beginners, productivity
Published: 2018-02-28 22:36:41

---
title: Upload a Website to GitHub Pages
published: true
description: This article will walk you step by step uploading a webpage with HTML, CSS, and JavaScript to GitHub Pages.  Before reading this tutorial, you should have a web page already created that you want to upload.  If you don’t have one yet, don’t worry!  Read this post http://programmingliftoff.com/create-basic-webpage-css-javascript/ to create a website in no time! Got your website ready?  Then read on!
tags: webdev, git, beginner, productivity
---

*This article was originally published on [programmingliftoff.com](http://programmingliftoff.com/) as [Upload a Website to GitHub Pages](http://programmingliftoff.com/upload-website-github-pages/).*

![Finished Website](https://thepracticaldev.s3.amazonaws.com/i/kx8jtwu695e1sj0eivf3.png)

<em>Note: Before following these steps you should have created a website on your local machine.  If you do not have a website yet, complete the tutorial <a href="http://programmingliftoff.com/create-basic-webpage-css-javascript/">Create a Basic Webpage with CSS and JavaScript</a> to create a website, then come back to this tutorial.</em>

Prefer to watch this tutorial instead of reading it?  Click <a href="https://www.youtube.com/watch?v=hAsDjEo9Oqw">here</a>.

You will need `git` installed on your computer to upload your website to GitHub.  If you don’t have it installed, visit <a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git" target="_blank">this site</a> and follow the instructions for your operating system.  Note that if you’re using Windows, I recommend installing <a href="https://desktop.github.com/" target="_blank">GitHub for Windows</a>.

Then, to set up git, type the following in the terminal (or Git Bash on Windows), replacing &lt;name&gt; and &lt;email&gt; with your name and email:
```bash
git config --global user.name <name>
git config --global user.email <email>
```

After installing and configuring git, log into GitHub and create a new repository.  Do not check the box to initialize the repository with a readme.  GitHub will then show you instructions for creating a new repository on the command line.

Next, open the terminal (or the ‘Git Bash’ program in Windows).  Then use the `cd` command to navigate to the folder that your website is in.  Once in the folder, type the commands that GitHub displayed after creating a new repository in the last step.  The commands will be similar to the following, with only the GitHub repository URL changing:
```bash
git init
git add .
git commit -m “Upload website”
git remote add origin git@github.com:programming-liftoff/github-pages-first-upload.git
git push -u origin master # If this command fails, click the link in the next section to learn how to setup a SSH key with GitHub.
```

<h3>Permission denied (publickey) when executing <code class="language-git">git push -u origin master</code></h3>
If you see the message "Permission denied (publickey)", you will need to setup a SSH key to use with GitHub.  To do this, read GitHub's article <a href="https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/" target="_blank">Generating a New SSH Key</a>.  Complete all the steps, and when you're done, be sure to <a href="https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/" target="_blank">Add your SSH Key to your GitHub Account</a>.

Now try executing the line <code class="language-git">git push -u origin master</code> and it should work!

<h3>Final Steps</h3>

Finally, go to the ‘Settings’ tab of the GitHub repository, scroll down to the GitHub Pages section, choose ‘Master Branch’ for the source, and click ‘Save’.  A URL will then be displayed in the GitHub Pages section.  Click on that URL to visit your webpage (Note: It may take several minutes for the webpage to show up at the URL).

Congratulations!  You have now uploaded you website live on the internet!  Feel free to post the URL to your website in the comments below so other people can checkout your sweet website!

If you had any trouble, <a href="https://www.youtube.com/watch?v=hAsDjEo9Oqw">watch the video tutorial on YouTube</a>.

Thanks for reading!
-Andrew @ Programming Liftoff