16

Just set up my GitHub Pages website and as far as I can tell, GitHub Pages will look for index.html in the parent directory (i.e. if my repo is in username.github.io, it will look for index.html in username.github.io/index.html).

If it cannot find index.html there, it renders out my README.md on the page instead.

Must the index.html file go there or is there a way to tell Pages to look for that file in let's say username.github.io/src/index.html?

4 Answers 4

7

You can try this: create a dummy index.html file at the root, and insert this line of code inside the head tag and give it the right path.

index.html

<meta http-equiv="refresh" content="0;url=https://yourname.github.io/myapplication/frontend/public/index.html" /> 

Note that the url is inside the content's quotations

Sign up to request clarification or add additional context in comments.

Comments

4

GitHub has now made that easy.
When you try to deploy your project, don't deploy it from a branch. Instead, do that using the GitHub Action option.
Choose jekyll, then a file called jekyll-gh-pages.yml, will open and inside it, you'll need to change the source to whatever you want.

jobs: # Build job build: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Setup Pages uses: actions/configure-pages@v3 - name: Build with Jekyll uses: actions/jekyll-build-pages@v1 with: source: ./dist/ // CHANGE THAT TO WHATEVER YOU WANT destination: ./_site - name: Upload artifact uses: actions/upload-pages-artifact@v2 

This will make the default folder ./dist.

1 Comment

Marking this as the accepted answer if GitHub added this feature in now, thanks for the post!
2

No.

You would need to change the site source to change the directory where Jekyll will read files, but this is a configuration setting that you cannot change in GitHub Pages:

https://help.github.com/articles/configuring-jekyll/#configuration-settings-you-cannot-change

You can, however, change the source to the docs folder in the settings of your GitHub repository.

See https://stackoverflow.com/a/41197820/2102854.

Comments

0

according to this gist, by cobyism, you can use subtrees (not to be confused with the subtree merge strategy):

git subtree push --prefix <your-path> origin gh-pages 

from the git-subtree docs on git's source code:

Subtrees allow subprojects to be included within a subdirectory of the main project, optionally including the subproject's entire history.

For example, you could include the source code for a library as a subdirectory of your application.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.