Can I have my GitHub Pages index.html in a subfolder of the repository?

Create a dummy index.html at the root and put this in your header:

<meta http-equiv="refresh" content="0; url=https://repo.github.io/folder/index.html">

Be sure to change the destination URL. This will instantly redirect from index.html to your folder/index.html.


Maybe you want to push a subtree. For instance, let's say you have the build/dist directory and there the Doxygen site is built.

After building, to make sure to commit all changes in that folder, then do the following.

git subtree push --prefix build/dist origin gh-pages

It's important that you don't have anything on the gh-pages branch, on local or origin.

All credit goes to: https://gist.github.com/cobyism/4730490

Initially I also thought of a redirect. But redirects feel like code smells, even HTTP redirects. Although sometimes unavoidable, here may be a cleaner solution, and it is probably what you were looking for.