问题
I have a github repository which I use gruntjs to build my static site. This builds all the files to a dist folder (that is a folder not in the root). So the index.html file and all the contents is in /dist folder
Currently I copy the content of dist folder to another github repository ( so contents is in root) so I can push out as a github page which is obviously bad due to manual prone errors.
Ideally I would just like to push my project containing the dist folder to gh-pages and somehow tell github to read from dist folder rather then root. Is this possible and how can I make it work.
回答1:
I'm not familiar with how GH pages work, but I suspect you could make the dist
folder your git repository (and not the parent dir), that would allow you to push directly.
回答2:
One approach would be to use redirection. If your root is in some/other/folder
, then you can create a top-level index.html
like this one:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Redirecting</title>
<meta http-equiv="REFRESH" content="0;url=some/other/folder">
</head>
<body>
<center>
Redirecting to the real root folder.
</center>
</body>
</html>
Obviously you don't have to include anything between the <body>
and </body>
tags.
The only downside is that the extra directory names will show up as part of the URL in the browser. But if the path is long, you can shorten it with a symbolic link.
来源:https://stackoverflow.com/questions/13468311/deploying-git-hub-pages-project-where-project-index-html-is-not-root-folder