Sign up ×
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It's 100% free, no registration required.

Is there a way to check what environment craft is running on - ie, dev or not dev - via the template.

For example:

{%if env is 'dev'%}
    hello dev
{% else %}
   hello world
{% endif %}
share|improve this question

1 Answer 1

up vote 10 down vote accepted

When developing locally on Craft you would most likely have devMode => true set in your config file and set to false for your production config.


return array(
 '' => array(
   'devMode' => true
 '' => array(
   'devMode' => false

So you could test whether craft is in dev mode and respond to that:

{% if craft.config.devMode %}
  You are in dev mode
{% else %}
  You are not in devmode
{% endif %}
share|improve this answer
You can also define totally custom variables in the same way (e.g. 'cache' => false{% if craft.config.cache %}) – carlcs Aug 12 '14 at 10:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.