Recently I finally figured out by chance how to set up a homepage for a GitHub project.

GitHub Pages

GitHub Pages is a service that lets users conveniently host project web pages on GitHub.
For example, this blog of mine is built with GitHub Pages.

But this way you can only host one project named
GitHub username + “.github.com” (lki.github.io).

What if I have another project that I also want to access by domain name?

So clever me used git submodule to solve this problem.

Git Submodule

git submodule is actually a pretty silly solution:

  1. To ensure the latest content, the parent project has to update along with subproject updates.

  2. This approach actually hacks jekyll build—doesn’t feel particularly reliable.

  3. Removing a git submodule is just way too painful!
    So don’t add git submodule unless necessary.

A Better Solution

The other day while browsing senior sister Xianzhe’s GitHub I found this Issue.

It says:

After pointing the homepage CNAME to zhangwenli.com, ovilia.github.io will redirect to zhangwenli.com.
The gh-pages branches of other projects xxx will automatically map to ovilia.github.io/xxx.

Oh! So GitHub by default maps the “gh-pages” branch of the some-repo project to some-one.github.com/some-repo.

So we can create a new branch to map the menu to /mymenu.

Summary

  1. GitHub projects can create a gh-pages branch to map under github.com to github.com/repository-name.

  2. Look more, learn more, try more.

  3. Unless it’s a brilliant hack, pursue best practice.