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

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, there are two ways to do it:

  1. You can set this in the UI:

In your site dashboard, go to settings > build &deploy > build-settings. The option is labeled “Base directory”.

  1. Or your can use a netlify.toml file and set the base dir:

[build]
base = "subDirectory"
publish = "subDirectory/dist/"
command = "npm run build"

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

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 @Pieparker Thank you,
I would never fix that if it wasn’t your help.

1 Like

:partying_face:

Happy to help!