问题
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 all. This, however, means that my index.html is in a subfolder of the repository and Github Pages isn't picking it up (I get a 404 when I try to access the Pages site). Is there any way to make Github recognise that index.html when it's in a subfolder? It is a project site.
回答1:
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.
回答2:
Maybe what you want is to push a subtree. For instance, let's say you have the build/dist
directory and there the Doxygen site is built.
After building, make sure to commit all changes in that folder the 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 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, probably what you where looking for.
回答3:
You now have the option to use /docs
folder of master
branch as the root of your github pages website.
回答4:
Answer by David Jacquel is awesome.
But if you're trying to serve your whole SPA personal blog from /dist
or /build
folder of github pages as I do, there's a beautiful dirty hack by Raphael Pedicini: https://github.com/rafrex/spa-github-pages.
He suggests that you create a proxy index.html
page and custom 404.html
page. If your user enters direct url of a subpage, e.g. https://example.github.io/blog/, github pages server will serve 404.html
with scripts that pass url as a set of params to a proxy index.html, which launches SPA.
I wouldn't duplicate his code here, as it very well might change over time.
回答5:
To use Doxygen
and gh-pages
, you need to:
- Create the file
.nojekyll
in the root of yourgh-pages
branch - Make sure you removed
.png
,.html
, and similars from your.gitignore
file And 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:
- GitHub Pages (github.io) doxygen generated page not found (404)
- How to automatically generate doxygen documentation using Travis
- Auto-deploying Doxygen documentation to gh-pages with Travis CI
- https://help.github.com/categories/github-pages-basics/
- Publish Your Project Documentation with GitHub Pages
- How to make an introduction page with Doxygen
回答6:
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 repo. Currently github-pages expects to find an index.html file in the root of your repo which it can't.
eg. lets say your current repo is 'test'. You create anew repo say, 'website', transfer your .html and other files which are required to the 'website' repo. Now you need to use 'website' repo as a sub-module inside the 'test' repo.
note: in the above schema you only need to use the 'gh-pages' branch-name in your 'website' repo while 'test' can still retain the master branch.
little example tutorial on git submodules
来源:https://stackoverflow.com/questions/25320356/can-i-have-my-github-pages-index-html-in-a-subfolder-of-the-repository