I\'m trying to use GitHub pages to host a Doxygen site. Ideally, I\'d like to be able to push the generated files and directories to GitHub without having to tweak them at a
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.
Try transferring your index.html file and all its dependencies into a new repository and then use that repository as a sub-module in you current repository. Currently GitHub Pages expects to find an index.html file in the root of your repository which it can't.
For example, let’s say your current repo is 'test'. You create anew repository say, 'website', transfer your .html and other files which are required to the 'website' repository. Now you need to use 'website' repository as a sub-module inside the 'test' repository.
Mote: in the above schema you only need to use the 'gh-pages' branch-name in your 'website' repository while 'test' can still retain the master branch.
A little example tutorial on Git submodules.
To use Doxygen
and gh-pages
, you need to:
.nojekyll
in the root of your gh-pages
branch .png
, .html
, and similars from your .gitignore
fileAnd finally, create the index.html
file in the root of your project:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="1;url=html/index.html">
<title>Page Redirection</title>
</head>
<body>
If you are not redirected automatically,
follow the <a href="html/index.html">link to the documentation</a>
</body>
</html>
References:
You now have the option to use the /docs
folder of the master
branch as the root of your GitHub Pages website.
The answer by David Jacquel is awesome.
But if you're trying to serve your whole SPA personal blog from the /dist
or /build
folder of GitHub Pages as I do, there's a beautiful dirty hack by Raphael Pedicini.
He suggests that you create a proxy index.html
page and custom 404.html
page. If your user enters the direct URL of a subpage, e.g. https://example.github.io/blog/, the GitHub Pages server will serve 404.html
with scripts that pass the URL as a set of parameters to a proxy index.html, which launches the SPA.
I won't duplicate his code here, as it very well might change over time.
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.