[Support Guide] What if my project folder is not the root of my git repository?

Last reviewed by Netlify Support staff: Dec 2023

There are some projects that live in a folder instead of the root of your git repository. If you need to deploy your site from a subdirectory, Netlify offers advanced monorepo configuration options for manually setting your directories in the UI or netlify.toml file, or relying on automatic monorepo detection to configure directories for you.

Manual Configuration

Via the UI

In your site dashboard, for the specific site you want to configure, go to Site Configuration > Build & deploy > build-settings. There, you can set the base, package (if applicable), and publish directories, as well as your build command:

Via the netlify.toml file

You can set the base and public directories as well as the build command in a netlify.toml file. The package directory can only be configured via the UI. This section in the netlify.toml file might look something like this:

[build]
base = "/site"
publish = "public"
command = "your build command"

Now, your builds will work from the subdirectory folder mentioned above! If you have any issues, comment below.

Automatic Monorepo Detection

When you create a new site from an existing repository, Netlify automatically scans the repo to see if it contains multiple sites. If so, Netlify displays a Site to Deploy dropdown menu containing a list of available sites and directories:

Note that enabling the base setting can have other effects on your site, which are described in this article and in more detail in our documentation.

1 Like

Hi @Dennis, we have a repo which has similar setup that the app is not at the root so in netlify.toml we have something like:

[build]
base = "frontend/foo"
publish = "frontend/foo/storyboo-static/"
command = "yarn storybooy-build"

But we always got this error failed during stage 'building site': Deploy directory 'frontend/foo/frontend/foo/storybook-static' does not exist Not sure why but seems the base got included twice for the deploy dir

Hi @zipme, it looks like this bug was introduced in the update that improves monorepo handling. We have an issue filed for it and will let you know as soon as we get things fixed.

Hi @Dennis, thanks for the prompt reply! In the meantime we use a workaround by skipping the base prefix in publish. So:

[build]
base = "frontend/foo"
publish = "storyboo-static/"
command = "yarn storybooy-build"
1 Like

thanks for sharing this, @zipme!

Sadly this doesn’t work for me.

had to redirect it instead.

On my netlify.toml i have something like:
[[redirects]]
from = "/"
to = "subdirectory/"

This absolutely should work @jayemfonacier and I believe that something else must be at play! If you’re happy with the workaround, great – otherwise, please create a topic and we can delve in on this one.

i should! i encountered issues with this work around. will post soon. thanks!

Hi, I deloyed a website on Netlify. This is a small website with a couple of pages,js and css, which they all live in a ‘dist’ folder. they are in my repo and the path is like this:
dist/index.html
So I changed my Publish directory using Netlify UI to ‘dist’. But it doesn’t work and Page Not Found is appeared after I click on automatically-generated domain name by Netlify.

What exactly should I write including / or . in Base directory, Build command, and Publish directory fields in Netlify UI?

Hi, @Pejmanc, if this is the site I think it is the following settings should work:

  • Base directory: (leave this blank)
  • Build command: (leave this blank)
  • Publish directory: dist

There should be no dots or forward slashes for “dist” (and no quotes either).

If this doesn’t work, please let us know (and please confirm which site is being tested).

Hi @luke, Thank you for your reply.
I changed my settings to the things you said, but it doesn’t work.
This is my site:
friendly-mccarthy-00cc03.netlify.app
Please let me know if I should provide you with more information.

Hey @Pejmanc,

I can see the site if I navigate to https://5f0df199e5fc91000708626a--friendly-mccarthy-00cc03.netlify.app/dist/index.html.

In your deploy log, I can see this:

6:55:42 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: 'dist' versus '/dist/' in the Netlify UI
6:55:42 PM: No build command found, continuing to publishing
6:55:42 PM: Starting to deploy site from ''

You will need to deploy your site again for the changes to take effect.

Oh @Scott Thank you,
I would never fix that if it wasn’t your help.

1 Like

:partying_face:

Happy to help!

@luke, @Scott. Hi there, I have a similar issue so I decided not to make an extra issue in forums for this.

I got a static (js, css, html only) website at my root folder which also contains a _headers file (no issue with it). But, there’s a folder named blog at <root>/blog and it is made with hugo - a static site generator. My issue here is how can I deploy hugo commands to build the website for the blog folder only.

I tried to use netlify.toml file in <root>/blog with the following code:-

[build]
command = "hugo --gc --minify"
publish = "public"

[build.environment]
GO_VERSION = "1.12"
HUGO_VERSION = "0.81.0"

but for some reason, it isn’t working. I don’t think there’s a way to run the environment variable and command in the netlify backend dashboard where there’s a option but as I said, my main website at root is a static website.

What do I do to make it work?