Base directory build setting ignored in netlify.toml

Hello,

I am running into an issue when trying to set the base directory for my site through the netlify.toml file. The publish directory and build commands, however, are being picked up. I am trying to deploy the site through Git, specifically Github. When I walk through the create a new site UI I see the publish directory and build command values coming through but do not see the base directory.

I then click the deploy site and navigate to the “Build and Deploy” tab in site settings. On this page I would expect to see the base directory value populated but instead see “Not Set”.

Screenshot_2020-03-03 Build deploy Settings

I have searched the forums and tried several different configurations to no avail. Here is my netlify.toml file:

# Settings in the [build] context are global and are applied to all contexts
# unless otherwise overridden by more specific contexts.

[build]
  # Directory to change to before starting a build.
  # This is where we will look for package.json/.nvmrc/etc.
  base = "frontend/"

  # Directory (relative to root of your repo) that contains the deploy-ready
  # HTML files and assets generated by the build. If a base directory has
  # been specified, include it in the publish directory path.
  publish = "frontend/build/"

  # Default build command.
  command = "npm run-script build"

# The following redirect is intended for use with most SPAs that handle
# routing internally.
[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200

I appreciate the help.

Hi, @tylerben, and welcome to our Netlify community site. :slight_smile:

I do see that both the build command and publish directory are auto-populated from netlify.toml but that the base directory is not.

Are you asking for the base directory to also be auto-populated from netlify.toml?

Hi @luke ,

Thanks for the reply. That is correct. Because I am setting the base key in the netlify.toml file, I would expect that the base directory field would be auto-populated in the settings UI. Is this not supported?

Hmmm… what you’re doing should work if your netlify.toml is in your root directory. Can you please share your Netlify site name and your repo if it’s public? That’ll let us take a closer look at your file structure.

I am experiencing the same issue. The public repo I am trying to deploy is at https://github.com/changelabsio/avl-tips

Heya @robert-bo-davis, can you please share your Netlify URL and say more about what issue you’re experiencing? When I look at your netlify.toml in that repo, I don’t see a base directory configured there. More on that here:

Let us know so can we dig in!

Sorry, we moved that project to lerna so the broken setup is no longer obvious in there. I forgot about this issue.

I set up a minimal test to try to reproduce and finally figured out what the problem for me was.

You can see the example here: https://github.com/interrobangc/netlifyDeployBug

That repo has a non master branch set to the default branch in github. The initial “deploy to netlify” button works, the site is created and bootstrapped, but since the master branch doesn’t have a netlify.toml file, the build fails.

My issue does not appear to be a bug in netlify. I assume that I just needed to set the production deploy context to the non standard branch. I haven’t take the time to test that though.

1 Like

On an unrelated note… plase let me know if I should open another issue somewhere.

In my testing, I did notice that the documentation says that the publish directory setting is relative to the root of the repo, but it appears to be relative to the base setting.

1 Like

You’re right on both counts!

Thanks so much for both coming back to share your process and making that example repo- makes it very easy to see the base vs. publish directory issue and I’m sure will be helpful for others who run into this same problem. I will reach out to our docs team to update that sample config.

Hi Jen,

Sorry for super late reply on this. I am still experiencing the issue I originally described. Here is a link to an example repo that functions similarly to the project I am working on.

The name of my site is example-netlify-toml-not-working and I was not able to successfully deploy the site as the result of the issues noted in my first two posts.

Of note in the deploy log were the following:

Different base path detected, going to use the one specified in the Netlify configuration file: 'frontend/' versus '' in the Netlify UI

And at the very end of the process

failed during stage 'building site': Deploy directory 'frontend/frontend/build' does not exist

So it looks like the base directory (value of “frontend/”) (while not being shown in the Netlify UI) is being read from the netlify.toml file and is being prepended to the publish value in the netfliy.toml (value of “frontend/build/”).

Any ideas as to why the base directory value does not show up in the Netlify UI and why it is being prepended to the publish directory?

Hey @tylerben, it seems like you may have gotten snagged by the same base vs. publish directory described by @robert-bo-davis above… as did I when I told you that your setup looked fine to me! Could you please try keeping your base as-is but making your publish directory “build”, so that your netlify.toml looks like:

# Settings in the [build] context are global and are applied to all contexts
# unless otherwise overridden by more specific contexts.
[build]
  # Directory to change to before starting a build.
  # This is where we will look for package.json/.nvmrc/etc.
  base = "frontend"

  # Directory (relative to root of your repo) that contains the deploy-ready
  # HTML files and assets generated by the build. If a base directory has
  # been specified, include it in the publish directory path.
  publish = "/build"

  # Default build command.
  command = "npm run-script build"

Please let me know if that fixes things for you!

As for the UI, the netlify.toml does take precedence over UI settings, so it makes sense that your values there are the ones that are used for the build. Are you saying that you would expect the netlify.toml values to appear in the UI if they are the ones being used?

Hi Jen,

Thanks for the help on this! Changing the netlify.toml to what you suggested resolved the deploy issue.

Re: Are you saying that you would expect the netlify.toml values to appear in the UI if they are the ones being used? That is correct. As the “Build command” and “Publish directory” fields are populated in the UI based on the values in netlify.toml, I would also expect that the “Base directory” value would be populated in the Netlify UI which it currently isn’t. So maybe not a bug but a improvement for the sake of consistency?

Here is what the build settings block looks like for me currently.

1 Like

Awesome, glad you’re up and running!

And what you’re saying makes sense, thanks for clarifying :slight_smile: I’ve added your comment to an internal GitHub issue about UI around the base directory setting. We’ll update here if we make changes on that front.

Awesome, thanks much!

1 Like

Hi @jen,

Just wanted to flag that the File based configuration help page still seems to say

If a base directory has been specified, include it in the publish directory path.

Just got caught by this issue again, so I thought I’d let you all know. :slight_smile:

1 Like

Hey @polybuildr,
Nooo, I’m sorry to hear that and very glad you found this thread! The reason those docs haven’t been updated yet is not due to lack of interest/urgency, but due to the fact that we want to make sure to fully document all of the impacts that setting a base directory can have. To point you to one public issue (there are also some private internal ones) where we’re discussing this:

We will be sure to update here once those updates have rolled out, and please continue to let us know how we can help in the meantime.

1 Like

Wanted to share a small update here, which is that we did change the wording in the sample configuration file:

[build]
  # Directory to change to before starting a build.
  # This is where we will look for package.json/.nvmrc/etc.
  base = "project/"

  # Directory that contains the deploy-ready HTML files and assets generated by
  # the build. This is relative to the base directory if one has been set, or the
  # root directory if a base has not been set. This sample publishes the
  # directory located at the absolute path "root/project/build-output"
  publish = "build-output/"
...

Thanks for the nudge @polybuildr :slight_smile:

Thanks, @jen! All clear now! :slight_smile:

Hi folks, I’m running into the same (or a very similar) problem.
I have a repo that has a directory called docs that contains the site I want to build (it’s documentation for a small package). I figured I could make a netlify.toml file in the repo root that looks like this:

[build]
  base = "docs/"
  publish = "_site/"
  command = "jekyll build"

…But unfortunately that doesn’t work. The netlify feedback says that that site is successfully published, but the url returns a 404. You can see an example here: https://app.netlify.com/sites/jolly-franklin-42244a/deploys/5f134061dec7c3000836408e
It’s showing some stuff that looks…wrong, like No build command found, continuing to publishing and Starting to deploy site from '' but I’m not sure how to debug those apart from the steps in this thread (which I’ve tried, and tried variations of). You can see my last several attempts to get it working in this rather embarrassing commit history: https://github.com/murmurcreative/module-drawer/commits/master

If you need any more debug information, please let me know!

Hey @alwaysblank,

Do you need to set them in a netlify.toml? If not, you can just add them in the UI :slight_smile:
https://app.netlify.com/sites/jolly-franklin-42244a/settings/deploys

Otherwise, your netlify.toml must reside in the root directory.

Does _site contain all of your HTML files, redirects, et cetera? Because that’s what the publish folder specifies.

Definitions are here. Happy to help further.