Build: Clarify where settings are loaded from

Created on 22 May 2020  路  7Comments  路  Source: netlify/build

If you set a base in netlify.toml, you need to create a second netlify.toml in that base directory to get things like redirects to work

This is fine, but _super_ unintuitive and not documented.

I think we can rectify this with relatively low effort:

  1. Log where settings are loaded from:

    [config] a `base` has been set. File-based settings will be sourced from 
    /path/to/base/netlify.toml -- see https://docs.link for more information
    
  2. Update our documentation for base to explain that it introduces the need for multiple netlify.toml files

documentation feature

Most helpful comment

Although there are other solutions that are recommended in this one use case, there was an issue when the user was trying to figure out why the redirects were not working. A solution like @jlengstorf is mentioning combined with some documentation might help the user to realize there is a configuration that will not work in their setup. It's not instantly apparent to the user why.

All 7 comments

We are logging where the netlify.toml was found and what is the "base" directory. (Note the screenshot below would show /opt/build/repo/base instead if a base directory was used).

base

Not sure if that's clear enough though, might need more copy?

@verythorough

@ehmicky This is good, but the issue specifically was an issue with this deploy

Where there are redirects in the /netlify.toml, but they are ignored because the base dir is in /website

[build]
  base = "website"
  publish = "build"
  command = "yarn build"

[[redirects]]
  from = "/en"
  to = "/"
  status = 301

[[redirects]]
  from = "/en/*"
  to = "/"
  status = 301

The solution:

/netlify.toml

[build]
  base = "website"

/website/netlify.toml

[build]
  publish = "build"
  command = "yarn build"

[[redirects]]
  from = "/en"
  to = "/"
  status = 301

[[redirects]]
  from = "/en/*"
  to = "/"
  status = 301

Although there are other solutions that are recommended in this one use case, there was an issue when the user was trying to figure out why the redirects were not working. A solution like @jlengstorf is mentioning combined with some documentation might help the user to realize there is a configuration that will not work in their setup. It's not instantly apparent to the user why.

The need to update the documentation may have been obsoleted by https://github.com/netlify/buildbot/pull/901, which brings the functionality more in-line with the existing documentation. Can someone verify if this is still a problem?

This was fixed by the PR linked above, thanks @bettse .

Was this page helpful?
0 / 5 - 0 ratings