Checking for an Acquia Environment variable Trying to check for an Acquia cloud environment variable in my twig template, but its not working in Dev or in Production. 

Similar question is answered here, but I still can't get the twig syntax right: Is there a way to get (and use) an environment variable in my Twig template?

This is a snippet from the page.html.twig file. 

{% if AH_SITE_ENVIRONMENT == 'prod' %}
  // Javascript Analytics Code
{% else %}
  &lt;!-- env is {{ AH_SITE_ENVIRONMENT }} --&gt;
{% endif %}
The other question mentioned having passed that variable from a preprocess function to the template first. I guess that can be done using PHP's getenv then. Let me just try that out.

Yep, that works.

/**
 * Implements template_preprocess_page().
 */
function MYTHEME_preprocess_page(&amp;$variables) {
  $variables['my_environment'] = getenv('AH_SITE_ENVIRONMENT');
}


Then continue in page.tpl.php.

{% if my_environment == "prod" %}
  // Javascript Analytics Code
{% else %}
  &lt;!-- env is {{ my_environment }} --&gt;
{% endif %}