I originally wrote this for Codecademy Groups, then transferred it to CodeHive once I found out about it after Groups had shut down, now I'm posting it back here :)
In this guide, we're going to learn how to host a site with GitHub Pages.
This guide assumes you're running Linux (or at least using a command line), and you're going to need to be signed into Github for this to work.
1. Head into the upper right corner on GitHub, and add a new repository:
2. Name the repository [your username].github.io:
I'm getting an error message because I'm already using GitHub to host my website, but you should be fine.
3. Next, open up your command line,
cd into the folder where you're planning on storing your project, and type this in:
git clone https://github.com/username/username.github.io, replacing username with your Github username:
$ git clone https://github.com/username/username.github.io.git
Cloning into 'username.github.io'...
remote: Counting objects: 551, done.
remote: Total 551 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (551/551), 37.37 MiB | 728.00 KiB/s, done.
Resolving deltas: 100% (292/292), done.
Checking connectivity... done.
cd into your new folder (
5. Move all of the files for your website into the folder you just created. Here's what I've got:
6. Back in your terminal, type in
git add --all
7. Type in
git commit -m "Initial commit"
8. Type in
git push. It'll ask you for your username and password; enter both:
$ git add --all
$ git commit -m "Initial Commit"
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean.
$ git push
Username for 'https://github.com':
Password for 'https://firstname.lastname@example.org':
To view your site, open up a browser and navigate to username.github.io
If you ever need to update a file, repeat the last 3 steps, and your update will be visible almost instantly.
It shouldn't take longer than 10-15 minutes before your site is live, however once it's up and running, updates will generally be pushed within 30 seconds.
If you can't get your site up following my instructions above, please reply below, and I'll try to help.
Also, read the Github Pages help docs
Was this helpful?
- Not really/only kind of
(If you choose anything other than yes, please let me know why!)