diff --git a/conda_devenv/devenv.py b/conda_devenv/devenv.py
index a89cf89..aad9646 100644
--- a/conda_devenv/devenv.py
+++ b/conda_devenv/devenv.py
@@ -7,16 +7,17 @@ import sys
 import six
 
 
-def render_jinja(contents, filename):
+def render_jinja(contents, filename, is_included):
     import jinja2
     import sys
     import platform
 
     jinja_dict = {
-        "root": os.path.dirname(os.path.abspath(filename)),
+        "is_included": is_included,
         "os": os,
-        "sys": sys,
         "platform": platform,
+        "root": os.path.dirname(os.path.abspath(filename)),
+        "sys": sys,
     }
 
     return jinja2.Template(contents).render(**jinja_dict)
@@ -49,7 +50,7 @@ def handle_includes(root_filename, root_yaml):
                         filename=filename
                     ))
             with open(included_filename, "r") as f:
-                jinja_contents = render_jinja(f.read(), included_filename)
+                jinja_contents = render_jinja(f.read(), included_filename, is_included=True)
             included_yaml_dict = yaml.safe_load(jinja_contents)
             if included_yaml_dict is None:
                 raise ValueError("The file '{included_filename}' which was"
@@ -182,7 +183,7 @@ def merge_dependencies_version_specifications(yaml_dict, key_to_merge):
 def load_yaml_dict(filename):
     with open(filename, "r") as f:
         contents = f.read()
-    rendered_contents = render_jinja(contents, filename)
+    rendered_contents = render_jinja(contents, filename, is_included=False)
 
     import yaml
     root_yaml = yaml.load(rendered_contents)

Add a way to identify if the current file is the "main" devenv file
diff --git a/tests/test_include.py b/tests/test_include.py
index f3eb7fc..308206d 100644
--- a/tests/test_include.py
+++ b/tests/test_include.py
@@ -7,7 +7,7 @@ from conda_devenv.devenv import handle_includes, render_jinja
 
 def obtain_yaml_dicts(root_yaml_filename):
     contents = open(root_yaml_filename, "r").read()
-    contents = render_jinja(contents, filename=root_yaml_filename)
+    contents = render_jinja(contents, filename=root_yaml_filename, is_included=False)
     root_yaml = yaml.load(contents)
     dicts = handle_includes(root_yaml_filename, root_yaml).values()
     dicts = list(dicts)
diff --git a/tests/test_jinja.py b/tests/test_jinja.py
index 551305e..b3ff3d8 100644
--- a/tests/test_jinja.py
+++ b/tests/test_jinja.py
@@ -10,7 +10,11 @@ from conda_devenv.devenv import render_jinja
 
 
 def test_jinja_root():
-    assert render_jinja("{{root}}", filename="path/to/file") == os.path.abspath("path/to")
+    assert render_jinja(
+        "{{root}}",
+        filename="path/to/file",
+        is_included=False,
+    ) == os.path.abspath("path/to")
 
 
 def test_jinja_os(monkeypatch):
@@ -22,13 +26,13 @@ def test_jinja_os(monkeypatch):
         {%- endif %}
     """).strip()
 
-    assert render_jinja(template, filename="") == "variable is not set"
+    assert render_jinja(template, filename="", is_included=False) == "variable is not set"
 
     monkeypatch.setenv('ENV_VARIABLE', '1')
-    assert render_jinja(template, filename="") == "variable is set"
+    assert render_jinja(template, filename="", is_included=False) == "variable is set"
 
     monkeypatch.setenv('ENV_VARIABLE', '2')
-    assert render_jinja(template, filename="") == "variable is not set"
+    assert render_jinja(template, filename="", is_included=False) == "variable is not set"
 
 
 def test_jinja_sys(monkeypatch):
@@ -43,27 +47,27 @@ def test_jinja_sys(monkeypatch):
     """).strip()
 
     monkeypatch.setattr(sys, 'platform', 'linux')
-    assert render_jinja(template, filename="") == "linux!"
+    assert render_jinja(template, filename="", is_included=False) == "linux!"
 
     monkeypatch.setattr(sys, 'platform', 'windows')
-    assert render_jinja(template, filename="") == "windows!"
+    assert render_jinja(template, filename="", is_included=False) == "windows!"
 
     monkeypatch.setattr(sys, 'platform', 'darwin')
-    assert render_jinja(template, filename="") == "others!"
+    assert render_jinja(template, filename="", is_included=False) == "others!"
 
 
 def test_jinja_platform(monkeypatch):
     template = "{{ platform.python_revision() }}"
-    assert render_jinja(template, filename="") == platform.python_revision()
+    assert render_jinja(template, filename="", is_included=False) == platform.python_revision()
 
 
 def test_jinja_invalid_template():
-    # TODO: change this to pytest's nicer syntax: with pytest.raises()
-    try:
-        render_jinja(textwrap.dedent("""\
+    with pytest.raises(jinja2.exceptions.TemplateSyntaxError):
+        render_jinja(
+            textwrap.dedent("""\
                 {%- if os.environ['ENV_VARIABLE'] == '1' %}
                 {% %}
-            """), filename="")
-        pytest.fail("Should raise an exception")
-    except jinja2.exceptions.TemplateSyntaxError as e:
-        pass
+            """),
+            filename="",
+            is_included=False,
+        )
diff --git a/tests/test_load_yaml_dict.py b/tests/test_load_yaml_dict.py
index 43ed3d5..3c9d6eb 100644
--- a/tests/test_load_yaml_dict.py
+++ b/tests/test_load_yaml_dict.py
@@ -63,3 +63,34 @@ def test_get_env_name(mocker, tmpdir, cmd_line_name):
         assert name == 'foo'
     else:
         assert name == 'bar'
+
+
+def test_is_included_var(datadir):
+    import six
+    import textwrap
+    a_env_file = datadir / 'a.devenv.yml'
+    a_env_file.write_text(six.text_type(textwrap.dedent('''\
+        name: a
+        includes:
+          - {{root}}/b.devenv.yml
+        environment:
+          VARIABLE: value_a
+          IS_A_INCLUDED: {{is_included}}
+    ''')))
+    b_env_file = datadir / 'b.devenv.yml'
+    b_env_file.write_text(six.text_type(textwrap.dedent('''\
+        name: b
+        environment:
+          {% if not is_included %}
+          VARIABLE: value_b
+          {% endif %}
+          IS_B_INCLUDED: {{is_included}}
+    ''')))
+
+    conda_env, os_env = load_yaml_dict(str(a_env_file))
+    assert conda_env == {'name': 'a'}
+    assert os_env == {
+        'IS_A_INCLUDED': False,
+        'IS_B_INCLUDED': True,
+        'VARIABLE': 'value_a',
+    }

pip install -e .
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y gcc
3.6
requirements_dev.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.13
attrs==22.2.0
Babel==2.11.0
bump2version==1.0.1
bumpversion==0.6.0
certifi==2021.5.30
cffi==1.15.1
charset-normalizer==2.0.12
-e git+https://github.com/ESSS/conda-devenv.git@f74b1ebc267d9c765e0f4851cf1154d3434a0e49#egg=conda_devenv
coverage==6.2
cryptography==40.0.2
distlib==0.3.9
docutils==0.18.1
filelock==3.4.1
flake8==3.9.2
idna==3.10
imagesize==1.4.1
importlib-metadata==4.8.3
importlib-resources==5.4.0
iniconfig==1.1.1
Jinja2==3.0.3
MarkupSafe==2.0.1
mccabe==0.6.1
packaging==21.3
platformdirs==2.4.0
pluggy==1.0.0
py==1.11.0
pycodestyle==2.7.0
pycparser==2.21
pyflakes==2.3.1
Pygments==2.14.0
pyparsing==3.1.4
pytest==7.0.1
pytest-datadir==1.4.1
pytest-mock==3.6.1
pytz==2025.2
PyYAML==6.0.1
requests==2.27.1
six==1.17.0
snowballstemmer==2.2.0
Sphinx==5.3.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
toml==0.10.2
tomli==1.2.3
tox==3.28.0
typing_extensions==4.1.1
urllib3==1.26.20
virtualenv==20.17.1
watchdog==2.3.1
zipp==3.6.0

name: conda-devenv
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.13
      - attrs==22.2.0
      - babel==2.11.0
      - bump2version==1.0.1
      - bumpversion==0.6.0
      - cffi==1.15.1
      - charset-normalizer==2.0.12
      - coverage==6.2
      - cryptography==40.0.2
      - distlib==0.3.9
      - docutils==0.18.1
      - filelock==3.4.1
      - flake8==3.9.2
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==4.8.3
      - importlib-resources==5.4.0
      - iniconfig==1.1.1
      - jinja2==3.0.3
      - markupsafe==2.0.1
      - mccabe==0.6.1
      - packaging==21.3
      - platformdirs==2.4.0
      - pluggy==1.0.0
      - py==1.11.0
      - pycodestyle==2.7.0
      - pycparser==2.21
      - pyflakes==2.3.1
      - pygments==2.14.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytest-datadir==1.4.1
      - pytest-mock==3.6.1
      - pytz==2025.2
      - pyyaml==6.0.1
      - requests==2.27.1
      - six==1.17.0
      - snowballstemmer==2.2.0
      - sphinx==5.3.0
      - sphinxcontrib-applehelp==1.0.2
      - sphinxcontrib-devhelp==1.0.2
      - sphinxcontrib-htmlhelp==2.0.0
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==1.0.3
      - sphinxcontrib-serializinghtml==1.1.5
      - toml==0.10.2
      - tomli==1.2.3
      - tox==3.28.0
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - virtualenv==20.17.1
      - watchdog==2.3.1
      - zipp==3.6.0
prefix: /opt/conda/envs/conda-devenv

tests/test_jinja.py::test_jinja_root tests/test_jinja.py::test_jinja_os tests/test_jinja.py::test_jinja_sys tests/test_jinja.py::test_jinja_platform tests/test_jinja.py::test_jinja_invalid_template
tests/test_include.py::test_include tests/test_include.py::test_include_non_dag tests/test_include.py::test_include_non_existent_file tests/test_include.py::test_include_file_with_relative_includes tests/test_include.py::test_include_empty_file tests/test_load_yaml_dict.py::test_load_yaml_dict tests/test_load_yaml_dict.py::test_load_yaml_dict_with_wrong_definition_at_environment_key tests/test_load_yaml_dict.py::test_load_yaml_dict_with_wrong_definition_at_environment_key_will_add_wrong_file_to_exception_message tests/test_load_yaml_dict.py::test_is_included_var
tests/test_load_yaml_dict.py::test_get_env_name[True] tests/test_load_yaml_dict.py::test_get_env_name[False]
conda_devenv/devenv.py
conda_devenv/devenv.py