Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I have my GitHub Pages index.html in a subfolder of the repository?

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 a way to make GitHub recognise that index.html when it's in a subfolder?

It is a project site.

like image 474
false_azure Avatar asked Aug 15 '14 02:08

false_azure


People also ask

How do I add index HTML to GitHub?

In your repo page and file-listing, click through index. html and click the Edit button, which will let you edit index. html via the Github file editor. Commit your changes.

Can you use HTML in GitHub Pages?

GitHub Pages lets you take a GitHub repository and turn it into a webpage. In other words, you can use a GitHub repository to host your HTML, CSS, and JavaScript files.

Can GitHub Pages be dynamic?

GitHub Pages is for static websites only. That is, websites that consist entirely of (X)HTML, JavaScript, CSS, and other static assets. GitHub Pages doesn't support dynamic websites or anything requiring a backend or secret data.


2 Answers

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.

like image 196
David Jacquel Avatar answered Oct 10 '22 10:10

David Jacquel


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.

like image 26
Agustín Amenabar Avatar answered Oct 10 '22 11:10

Agustín Amenabar