Deploying Git Hub Pages project where project (index.html) is not root folder

时光毁灭记忆、已成空白 提交于 2019-12-24 16:14:20

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!