Hello! I’ve recently updated my netlify-cli to the latest version, and since there, the {{ jekyll.environment }}
variable in my local sites is set to “production” by default, and I don’t find how to set it to development
. The Jekyll docs hasn’t helped me. Thank you in advance.
win32-x64
node-v15.6.0
netlify-cli/3.2.3 (issue persist)
netlify-cli/3.4.0 (issue persist too)
You can use netlify.toml
to specify environment variables like this:
[build]
context = "development"
[context.development.environment]
JEKYLL_ENV = "development"
It works in Netlify UI, so I’d suppose that it works in CLI too.
Thank you for your proposition, but it doesn’t work in this case.
The following setting works, but it will be applied in production too.
[build.environment]
JEKYLL_ENV = "development"
This doesn’t change anything:
# Does not exist, just a try.
[dev.environment]
JEKYLL_ENV = "development"
You missed the context
keyword, but that’s alright since it’s working now.
I didn’t miss a thing. I have copied and pasted your code as is into mine, but the environment remains in production
. Yes, it works with:
[build.environment]
JEKYLL_ENV = "development"
But aren’t there other ways to separate the development and production environment?
Well then, sadly I don’t know of any other way other than manually setting the EVs in your Netlify dashboard. What I suggested works for me in my Hugo website, so I thought it would work with others too.
At best, you could create 2 websites, connected to the same repo, and different EVs in the dashboard.
1 Like
Hey @jdbruxelles
If you want to set an environment variable exclusively for netlify dev
, I’d recommend just using a .env
file. Netlify Dev respects .env files and injects the variables in local development
JEKYLL_ENV=development
–
Jon
2 Likes
Thank you, @jonsully. It works with/in .env
file.
1 Like