How to build pages to baseurl directory

Is it possible to build my github pages into a specifically named directory rather than root?

Currently, my project is deployed to the wwwroot of . so that it can be accessed at but I would like it to deploy at so that all of the existing paths and references work when it is run locally or deployed to other locations as well.

The only workaround I can think of is to set up an action to manually run jekyll and deploy the generated _site folder into the gh-pages branch in a folder called foo but that really seems inefficient and will result in a really large repo given all the various html files and whatnot.

Github Pages Action will do this, but requires running a third party action and I would like to keep my project as simple as possible given that github is already running jekyll and generating all the content.


If you name your repository foo, you will get the behavior you are after. Namely, the Pages site will resolve at: https://<your user name><repo name>.

Hope that helps,

Thanks for the response, but that’s not how it works for enterprise, private repos. Or at least it doesn’t work in a way that Jekyll likes.

If I have the org, Bar, and I name my repo Foo, then going to will redirect to a uniquely generated name like and serve up the pages, so the basedir is lost (and all my context links are broken since the site expects to be situated in a “foo” folder).

You are correct. I should have mentioned that. For security reasons, private pages cannot be served anywhere but on a dedicated domain/subdomain.

Nothing prevents you from moving your content under a foo folder but there is nothing else Pages will do automatically for you here.

Thanks for the suggestion, but moving content under a foo folder would break the other jekyll builds that respect the site.basedir property in _config.yml, and then means that any changes to the basedir would require moving all the files and manually changing all the permalinks each time. For example my “home page” has a permalink to “/” that I expect to be served at It’s already in the pages folder so moving to a pages/foo won’t affect how jekyll generates it unless I update the front matter to have permalink set to “foo/” and that times dozens of pages, etc etc.

I am trying to understand your scenario better.

Since you are now publishing your site has a private Pages site, it is going to be served at the root of a domain (just like it would be with a public Pages site using a custom domain).

Wouldn’t updating your files to treat / as your root be sufficient for both local and “deployed” scenarios?

In my front matter on my homepage sets permalink=/ but the _config.yml has basedir=foo so for my local deployment and my gitlab pages deployment the site is deployed to “https://otherurl.whatever/foo”.

The same source code will be deployed and hosted at multiple locations so the problem is that a “regular” jekyll build deploys the pages into a “foo” folder and all the links prefix permalinks with the basedir as well.

Ok I get it, thank you for the explanation.

I am afraid this is unfortunately not a scenario we support today on top of private Pages.

Thanks for confirming, I’ll keep an eye out for if this functionality gets added in.