Creating a User Pages Site5:39 with Guil Hernandez
Learn how to host a User Pages site on GitHub Pages. User Pages websites are stored in a special repository dedicated to your GitHub Pages files. As a GitHub user, you’re entitled to one free user website per account. User Pages are commonly used for hosting a portfolio website or an organization's main website.
- The command
rm -rf .gitremoves the local Git repository for a project.
- Adding an existing project to GitHub using the command line
- Creating project pages manually
- As a GitHub user, you're allowed one free User Pages website per account.
- Not every repository can have its own user website.
- The URL for a User Pages website looks like this:
courses.github.io— the username followed by the GitHub pages domain.
- You don't create a 'gh-pages' branch for User Pages sites.
- You push all files and changes to the 'master' branch.
GitHub also gives you the option to host your websites as user pages websites. 0:00 User pages websites are nearly identical to the Project Pages websites I 0:04 covered earlier. 0:08 The only differences are that as a GitHub user, 0:09 you're allowed one free user pages website per account. 0:12 Not every repository can have its own user website. 0:15 That's because user pages use your accounts user name in the URL. 0:18 Your URL will look like this, the user name followed by the github domain. 0:22 And unlike project pages, you don't create a gh-pages branch for user pages. 0:27 You just place the files in the master branch of the repository and you're done. 0:32 This makes user pages ideal for hosting your portfolio website. 0:36 So in this video the steps I'm going to take to host my site 0:40 as a user pages website are, first initialize a local repository for 0:43 the project, then add the repository to GitHub using a specific naming convention. 0:47 Then we'll wait for GitHub pages to build the site. 0:53 Again, it usually takes no more than ten minutes. 0:55 Let's get to it. 0:58 With user pages, you create a brand new repository. 1:00 And all the repository's for is your website. 1:03 You don't even need to create a GH pages branch 1:05 like you need to with project pages. 1:08 So I'm gonna create my user pages repository using my GitHub account, and 1:10 all my website files will be hosted here. 1:14 So first up, like I did earlier with project pages, 1:18 I need to initialize a local git repository for 1:20 my courses website project that's in my home directory. 1:24 So back in the terminal I'll navigate to the courses directory by typing 1:27 the command cd courses. 1:31 For this lesson I deleted the local git repository and 1:34 branch I created earlier for the project pages website. 1:37 So here I'm starting fresh. 1:41 Now to learn how to do that be sure to take a look at the teacher's notes. 1:43 So you'll notice that if I run a git status 1:47 it tells me there's no git repository for this project. 1:51 So now to initialize a new git repository, I can type the command git init and 1:54 this creates a new empty git repository on my computer for the course's project. 2:01 And if I run I git status now it lists all my project files as untracked files. 2:07 So now I need to tell git to add these files to staging by typing the command git 2:13 add followed by a period. 2:18 And then I'll commit them by typing git commit -m, 2:21 and as the commit message I'll say, initial commit. 2:27 So now that I've committed my files to the local git repository, I need to go to my 2:34 GitHub account and create a remote repository for this project. 2:39 So back in my GitHub account, I'll click New to create a new repository. 2:44 And as the repository name, 2:49 I have to use a specific naming convention GitHub requires for user pages websites. 2:51 So, I'm going to name mine gilh.github.io. 2:56 So the account username followed by the GitHub domain. 3:03 Go ahead and use your account name here. 3:08 So next, if I leave initialize with a README unchecked and 3:11 click Create repository, 3:15 the next page gives me the commands I need to create a remote repository. 3:17 So now I want to create the repository by pushing an existing repository 3:23 from the command line. 3:27 So if I copy these commands here and paste them in the terminal. 3:28 Once I hit Enter, Git pushes the files from my local repository 3:35 to this remote GitHub repository. 3:39 And any changes I push to this repository will show up on the website. 3:42 So GitHub is now building my user pages website. 3:46 And as I mentioned earlier it usually takes no longer than ten minutes to 3:50 view the site with the GitHub pages domain. 3:53 So let's try it out. 3:55 So he URL for my website is guilh.github.io, 3:58 so the account username followed by the GitHub pages domain. 4:05 All right great, so now my website is hosted as a user pages website. 4:10 And making changes to your user pages website is also simple. 4:16 First, you make the changes to your project in your local project folder, 4:20 then you push those changes to the master branch 4:23 of your user pages website repository. 4:26 So like I did in the previous video, 4:29 I'm going to add some of my latest Treehouse workshops to this page. 4:31 So I'll simply open up the project's index.html file and 4:36 then I'll paste in the code for the workshops, and hit Save. 4:40 All right, so now I'm ready to publish these changes on GitHub Pages. 4:44 So back in terminal, if I run the git status command, 4:48 it lists the modified index.html file. 4:52 So next I'm going to add the changes to my staging are and 4:56 commit them to my local repository by typing git add. 5:00 And then I'll commit them by typing commit -m, and 5:05 as the commit message I'll write, add workshops. 5:11 And finally I'll push the changes up to the remote GitHub 5:19 repository with the command git push origin master. 5:24 So now if I go back to my website and refresh it, 5:31 great, my latest changes show up on the site. 5:34
You need to sign up for Treehouse in order to download course files.Sign up