Bit of a random question which I am trying it myself and will post an answer if I figure it out. Can you use “$URL/something” in both the UI and the toml file? Which one takes precedence, the UI or build.environment?

If so do you need the " " around it in the UI for the interpolation to replace $URL with the sites main url?

First off, I don’t recommend any pattern of trying to play precedence games between the UI and the toml file; the toml file is ideal to handle ALL variables because it has ability to set a default AND a per-branch or build type context:

Second, you wouldn’t be able to refer to one environment variable from another like that. The values need to be static, and need to be interpolated manually at build time, no matter where you define them. This article has some more details on the successful use of envvars at Netlify:

The preferred way to use environment variables in Netlify is to set them in our environment - be that in the Build Environment Variables configuration widget (on the site’s “Build & Deploy settings” page), or via netlify.toml. The latter is a bit more flexible as you can set different values for different contexts - e.g. staging uses a staging $API_ENDPOINT and production uses a production one; the former is a bit more secure, since only people with access to the Netlify admin UI for your site c…

Specifically, you’ll have to BUILD a value AT BUILD TIME from $URL or $DEPLOY_PRIME_URL plus your path, and you can do contextually different build commands to handle that, something like this (untested but I think it will work)