--- title: How do I use GitHub Pages? slug: Learn/Common_questions/Using_Github_pages translation_of: Learn/Common_questions/Using_Github_pages ---
GitHub is a "social coding" site. It allows you to upload code repositories for storage in thecelio Git version control system. You can then collaborate on code projects, and the system is open-source by default, meaning that anyone in the world can find your GitHub code, use it, learn from it, and improve on it. You can do that with other people's code too! This article provides a basic guide to publishing content using Github's gh-pages feature.
GitHub is a very important and useful community to get involved in, and Git/GitHub is a very popular version control system — most tech companies now use it in their workflow. GitHub has a very useful feature called GitHub Pages, which allows you to publish website code live on the Web.
You can store any code you like in a Github repository, but to use the GitHub Pages feature to full effect, your code should be structured as a typical website, e.g. with the primary entry point being an HTML file called index.html
.
The other thing you need to do before moving on is to initialise your code directory as a Git repository. To do this:
test-site
directory (or whatever you called the directory containing your website). For this, use the cd
command (i.e. "change directory"). Here's what you'd type if you've put your website in a directory called test-site
on your desktop:
cd Desktop/test-site
git
tool to turn the directory into a git repository:
git init
The best way to upload your code to Github is via the command line — this is a window where you type in commands to do things like create files and run programs, rather than clicking inside a user interface. It will look something like this:
Note: You could also consider using a Git graphical user interface to do the same work, if you feel uncomfortable with the command line.
Every operating system comes with a command line tool:
This may seem a bit scary at first, but don't worry — you'll soon get the hang of the basics. You tell the computer to do something in the terminal by typing in a command and hitting Enter, as seen above.
git remote add origin https://github.com/chrisdavidmills/my-repository.git
git add --all git commit -m 'adding my files to my repository'
git push -u origin master
Note: If you get stuck, the GitHub Pages homepage is also really helpful.
If you want to make more changes to your test site and upload those to GitHub, you simply need to make the change to your files just like you did before. Then, you need to enter the following commands (pressing Enter after each one) to push those changes to GitHub:
git add --all git commit -m 'another commit' git push
You can replace another commit with a more suitable message to describe what change you just made.
We have barely scratched the surface of Git. To learn more, start off with the GitHub Help site.