I'm new to web development and looking for advice on how to manage global 'environment' values for a static site. I initially thought .env files could be the solution, but after asking in a web dev Discord, I got mixed feedback about using them for non-sensitive data since that's not their primary purpose. I then considered using JSON files, which I understand are good for storing and transferring data, but I'm unsure if that's appropriate for a static site that doesn't use a backend. Ideally, I want a lightweight method to manage values that I might need to change frequently, like file paths depending on where my site is hosted (e.g., GitHub Pages vs. Netlify). What's the best approach for this?
1 Answer
A great approach is to let your build process handle environment differences. If you're loading a JSON file on every page, that’s doable, but it might be better to handle it at build time to keep things clean and efficient. Plus, if you package your site, it avoids overloading the client with unnecessary data loads.
Thanks for the insight! I think understanding this before I go too far is super helpful. I’ll definitely dive into how to set that up!