In the previous section, we created a web application using Jekyll, Backbone, and D3. With Jekyll, we created a template for the main page and included the minified JavaScript libraries and styles. With Jekyll, we can compile the markup files to generate a static website or serve the site without generating a static version using jekyll serve
. In this section, we will publish our site using GitHub Pages, a hosting service for personal and project sites.
GitHub Pages is a service from GitHub that provides hosting for static websites created in Jekyll or HTML. To publish our Jekyll site, we need to create a branch named gh-pages
and push the branch to GitHub. If this branch is a Jekyll project or contains an index.html
file, GitHub will serve the content of this branch as a static site. We can create the branch from the master branch:
$ git checkout -b gh-pages
Next, push the branch to our origin, the GitHub endpoint:
$ git push -u origin gh-pages
This will push the gh-pages
branch to GitHub, and GitHub Pages will generate the site in a few minutes. The application will be published and will be accessible through an URL of the form http://user.github.io/project-name
, in our case, http://pnavarrc.github.io/hdi-explorer. It's important to remember that the base URL for the project will be http://user.github.io/project-name
. Set the baseurl
variable in the _config.yml
file correctly to avoid path problems with the styles and JavaScript files.
We can create personal pages as well, but in this case, we would need to create a repository with a name of the form user.github.io
, and the site will be a server from the http://user.github.io
URL. GitHub Pages also allows you to use custom domains and plain HTML instead of Jekyll. More information about GitHub Pages can be found in the project site at http://pages.github.com/.