# Variable not set after template import.

**URL:** <https://community.hubspot.com/t/variable-not-set-after-template-import/83770>\
**Category:** CMS Development\
**Tags:** enterprise\
**Created:** [June 20, 2023, 4:59pm UTC](https://community.hubspot.com/t/variable-not-set-after-template-import/83770 "2023-06-20T16:59:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevinfilteau](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kevinfilteau/32/72047_2.png) [@kevinfilteau](https://community.hubspot.com/u/kevinfilteau)\
**Post date:** [June 20, 2023, 4:59pm UTC](https://community.hubspot.com/t/variable-not-set-after-template-import/83770/1 "2023-06-20T16:59:50Z")

</div>

# Variable not importing

I have been trying to run four templates using the same code file in the include. Everything works properly except for one of the template. Templates are loaded from three different domains.

However, when I add hsDebug=true, it works on all.

I have spent several hours trying different things, but nothing has worked so far. Anyone has a clue ?? Thank you !

This is the part of the code in the template file :

```auto
<!--
 templateType: page
 isAvailableForNewContent: true
 label: Specific
 screenshotPath: ../images/template-previews/specific.png
-->
<!doctype html>
<html lang="{{ html_lang }}" {{ html_lang_dir }}>
 <head>
 <meta charset="utf-8">
 {% if page_meta.html_title || pageTitle %}<title>{{ page_meta.html_title || pageTitle }}</title>{% endif %}
 {% if site_settings.favicon_src %}<link rel="shortcut icon" href="{{ site_settings.favicon_src }}" />{% endif %}
 {% if page_meta.meta_description %}<meta name="description" content="{{ page_meta.meta_description }}">{% endif %}

 {{ require_css(get_asset_url("../css/theme.css")) }}
 {{ require_css(get_public_template_url("../child.css"), {async:true}) }}
 {% if template_css %}
 {{ require_css(get_asset_url(template_css), {async:true}) }}
 {% endif %}
 {{ standard_header_includes }}

 {%- import "../macros/shared-meta.html" as shared -%}
 {{ shared.load_settings() }}

 <script>
 var debug_shared_4 = {{ shared | pprint }};
 var debug_settings_4 = {{ shared.settings | tojson }};
 var debug_data_4 = {{ shared.data | tojson }}
 </script>

```

And this is the included file containing the macro :

```auto
<!--
templateType: page
isAvailableForNewContent: false
label: Storefront shared settings.
-->
<!-- Begin partial -->

{% set props = {
 "domains": ["domain-a.com", "domain-b.com", "domain-c.com", "domain-d.com"],
 "locales": ["en_CA", "en_US", "fr_CA"]
 } 
%}

{% set course = {} %}
{% set settings = {} %}
{% set data = {} %}

{# 
 Load storefront settings from the database table settings.
#}
{% macro load_settings() -%}

 {% set dom = request.query_dict.domain is defined ? request.query_dict.domain : request.domain %} 
 {% set loc = request.query_dict.locale is defined ? request.query_dict.locale : locale %}

 {% if dom in props.domains %}
 {% do props.update({"domain": dom}) %}
 {% do data.update({"domain": dom}) %}
 {% endif %}

 {% if loc in props.locales %}
 {% do props.update({"locale": loc}) %}
 {% do data.update({"locale": loc}) %}
 {% endif %}

 {% if data.domain is defined and data.locale is defined %}
 {% set settings_filter = "domain=" ~ data.domain ~ "&locale=" ~ data.locale %}
 {% set items = hubdb_table_rows("settings", settings_filter) %}
 {% for item in items %}
 {% do settings.put(item.name,item.value) %}
 {% endfor %}
 {% endif %}

 <script id="shared-meta-debug">
 var debug_dom_sh = "{{ dom }}";
 var debug_loc_sh = "{{ loc }}";
 var debug_settings_sh = {{ settings|tojson }};
 </script>

{% endmacro %}

```

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [June 21, 2023, 7:20am UTC](https://community.hubspot.com/t/variable-not-set-after-template-import/83770/2 "2023-06-21T07:20:42Z")

</div>

Hello @kevinfilteau

Check the load\_settings() macro to make sure that the domain and locale variables are being set correctly.

If the domain and locale variables are being set correctly, try adding the hsDebug=true parameter to the URL of the template. This will enable debug mode, which will help you to track down the problem. If you are still having trouble try to provide more info such as the exact error message you are getting. I will do my best to help you resolve the issue.

---

<div class="post-metadata">

**Author:** ![kevinfilteau](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kevinfilteau/32/72047_2.png) [@kevinfilteau](https://community.hubspot.com/u/kevinfilteau)\
**Post date:** [June 21, 2023, 11:59am UTC](https://community.hubspot.com/t/variable-not-set-after-template-import/83770/3 "2023-06-21T11:59:52Z")

</div>

Hello @himanshurauthan

Thank you for you fast response. I already tried hsDebug and many other things. I forgot to explaing that inside the function I got the data loaded correctly. But not outside after the call. Except under hsdebug. Here’s more : )

 ![SCR-20230621-hdtk.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/6/6c9f7331f1a889a34560cdade32bc8329d3feb88.png)

 ![SCR-20230621-hdge.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/8/8/88d2f4cd2e3a54efc27d473163e626ea5be75fd0.png)

 ![SCR-20230621-hfgp.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/c/4/c49efcc4141ce9239559625452001b286fadb4de.png)

And with hsDebug

 ![SCR-20230621-hira.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/3/9/392b6edeb6c0834533b3ba45ca7813a50f9588ba.png)

 ![SCR-20230621-hkmk.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/9/7/9703fb40e5066d545730cbf6c937db560f143f91.png)

 ![SCR-20230620-lczw.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/3/7/378889cec798576c76fd057f88eb0808678f4ebd.jpeg)
