R
R
ravshan selimov2020-10-17 10:01:47
GitHub
ravshan selimov, 2020-10-17 10:01:47

How to change site root directory in github-pages?

Hello.
How can I change the site root directory in github-pages?
Googled but didn't understand anything, couldn't.

It is necessary that when username.github.io is opened , username.github.io/build is opened ,
so that all styles, scripts, media downloads relative to build. To have username.github.io
in the address bar instead of username.github.io/build . Does gh-pages use .htaccess, if so how can it be done. Tried

RewriteEngine on
DirectoryIndex build

doesn't work, is there any way to do it with RewriteRule

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
Lesha, 2020-10-17
@ravshan01

Github Pages doesn't accept .htaccess. (this is not hosting) And you can't change the root directory as you want either.
There are 2 options:
1. Create a separate branch with site files and connect this branch to gh-pages
2. Create an empty page at the root with a redirect to /build

B
bqio, 2020-10-17
@bqio

Github Pages is a static website hosting. This information should be enough to understand.

K
ksnk, 2020-10-17
@ksnk

There is a base tag - htmlbook.ru/html/base . If you use it, then all relative links on the page will start from where this base looks. If you need a link to another place, you can put / at the beginning of the link. In principle, the reception is quite convenient, with careful use, when you need to switch topics on the site. Although sometimes you can fly into that still hemorrhoids. For example, href="#" specified on such a page at / will point not to the same page, but to the page /build/# Well, of course, the page itself must remain at the root, after all, static hosting
<base href="/build">

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question