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

I have a github repository that I use gruntjs to create my static site. This creates all the files in the dist folder (this folder is not in the root directory). So the index.html file and all the contents are in the / dist folder

I am currently copying the contents of the dist folder to another github repository (so that the content is in the root directory), so I can pop out the github page, which is obviously bad due to manual errors.

Ideally, I just would like to push my project containing the dist folder to the gh pages and somehow tell github to read from the dist folder, not root. Is this possible, and how can I make it work.

+1
github-pages
source share
2 answers

I am not familiar with how GH pages work, but I suspect that you could make the dist folder your git repository (and not the parent dir), which allows you to directly click.

+1
source share

One approach is to use redirection. If your root is in some/other/folder , you can create a top-level index.html like this:

 <!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 do not need to include anything between the <body> and </body> tags.

The only drawback is that additional directory names will be displayed as part of the URL in the browser. But if the path is long, you can shorten it with a symbolic link.

0
source share

All Articles