1.2 Create a Public Webpage with GitHub Pages
This tutorial will show you how to create a publically accessible webpage that you can share with your family and friends using GitHub Pages.
Pre-Requisites
You should already have the following set up…
Registrations
Installations
-
Note: CLI stand for Command Prompt Interface. These are command we can run in Command Prompt or Terminal.
Get access GitHub Pages code
Here is a short video that provides an example of what you will be doing at the Command Prompt on both your Mac or Windows PC.
- Open Terminal/Command Prompt
- If you are on a MAC or a Windows PC run the following commands for each platform.
-
Create a folder to hold your repository (Mac, Linux & Windows)
cd DocumentsNote: This should be your Documents folder on your Mac
mkdir resume-appNote:
mkdircreates a folder in the documents foldercd resume-appNote:
cdchanges directory to the folder you just created
-
-
Run the following commands.
- Create a new branch
git initNote:
git initinitialises the directory and creates a .git file so the git can track things locally. - Configure user name and email for github in command line
git config --global user.name "<enter-your-username>" git config --global user.email "<enter-your-github-email>" git config --global --listNote: Remove aligator clips
<&> - Add the your new repository to your local git directory
git remote add origin <the URL you copied from "quik setup" in the last step should be pasted here>Note: Remove aligator clips
<&>Note: We are adding your new remote repository to the new local git directory.
Example:
The command should look like this:
git remote add origin https://github.com/jjovah/myressapp5.git - Create a new branch and switch to the branch
git checkout -b gh-pagesNote: We are creating and switchig to our new gh-pages branch.
- Get code for webpage
git pull https://github.com/blackcodecamp/CloudWebDevelopment.git gh-pages --rebaseNote: We are downloading code from the URL provided.
- Update Remote Repo
git push --set-upstream origin gh-pagesNote: We are pushing the code to our newly created branch in our new repository.
- Create a new branch
Edit your website
- Open your IDE, VS Code
- Open the folder where you stored your repository by opeining the menu and clicking
FilethenOpen Folder - Then select to your
~\Documents\resume-appfolder - Open
index.htmlby clicking the file name in the Explorer on the right side - Once the html file is open in VS Code, edit the HTML file with your information. See Example
- Once editing is complete, save your changes by going to the menu and clicking
FilethenSave - In the menu click
Terminaland thenNew Terminalto open the Terminal window in VS Code. - Run the following commands
- Make sure you are in your git directory.
cd Documents\resume-app - Add all changes to staging area
git add --all - Store changes in version history
git commit -am "<descriptive-message>"Note: Your descriptive message can be “My First Change”
Note: Remove aligator clips
<&> - Send changes to remote repository
git push
- Make sure you are in your git directory.
Deploy To GitHub Pages
- Navigate to Your Repository in your browser https://github.com/
- In the menu bar under your repository title click on
Settings - In the left side menu under
Code and AutomationselectPages - Under
SourceselectDeploy from a branch - Under
Branchselectgh-pages -
When your page is ready you will see a message at the top of this page under
GitHubPagesthat says ‘Your site is live athttps://<github-username>.github.io/<your-repo-name>’Note: Remove aligator clips
<&> - Visit your site!