

If you are using user-pages the file should be placed in the master branch. This file should be placed in the gh-pages branch if you are using project-pages (as we have been in this post). The last thing I want to cover in this post is how you can use your own domain name with your new GitHub-hosted website.įirst you will need to create a new file in your GitHub repo called CNAME that contains the domain name (or subdomain) that you wish to use. That’s it! Your website should now be available at / repository/. The only thing left to do now is to push the new gh-pages branch up to GitHub. Okay so you’ve got all your files where they need to be. Note: The -a flag is shorthand for git add. To do this you can use the following command. Once you have added these to your repo you need to commit the changes. Now that your repo has been properly setup it’s time to add all of the HTML, CSS and JavaScript files that make up your website. To do this you can use the following command: git rm -rf. If you already had files in the master branch of your GitHub repo you now need to delete these from the new gh-pages branch. This new branch should be called gh-pages. Now you need to create a new orphan branch within your repo that will hold all of your website files. This can be found on the main project page. Note: Make sure that you change the clone URL to the URL of your GitHub repo. Once you got your local copy, move into the project folder using the cd command. Now open up terminal (command prompt on Windows) and make sure that you have a copy of your GitHub repo on your computer. Note: If you are not adding your website files to an existing repo make sure that you setup a new repo before continuing. If you’re creating a website to promote one of your existing GitHub projects you can add the website files to a new branch, otherwise you can just setup a new repo for your site.

The files that make up your website will need to be stored within a GitHub repository. Note: This post assumes that you have a GitHub account and some basic knowledge of the version control system Git. If you just want to launch a simple static website you can use GitHub Pages to host your site for free. So you want to launch a simple website but don’t want to have to go through the dull process of setting up yet another hosting package. So, add a destination key in _config.yml and set it to. Since we are deploying this to GitHub pages, by default it uses the content of docs directory in your repository. So, baseurl should be /REPOSITORY-NAME part of your URL, and url should be part of your URL. When creating a website in GitHub pages, usually the format of the URL will be: destination: The directory in which the build goes to.url: this is the main URL of the website.baseurl: this needs to be the subpath of the website.In _config.yml you need to change three key values: There are some changes you need to make in the website. Click Save, and GitHub will start compiling your website. Here, you will need to pick a Source branch and then the root directory. Next, go to Settings and scroll down to GitHub Pages If not, then create one and commit your work to it. Once you are done making the website, you can now deploy it on GitHub pages for free.įirst, you need to have a repository for your website on GitHub. If you now refresh the page, you'll see that the site title color is red.
GITHUB PAGES FREE CODE
The previous head code can be used, as assets/styles.sass will be compiled to assets/styles.css. After that, you can add any styles you need.įinally, we need to import it in the of the page. The first two dash lines tells Jekyll to compile and add this file to the build.
