# How can i add model configuration (using a macro on {{this}}) in dbt\_project.yml

**URL:** <https://discourse.getdbt.com/t/how-can-i-add-model-configuration-using-a-macro-on-this-in-dbt-project-yml/5910>\
**Category:** Help\
**Tags:** jinja\
**Created:** [January 4, 2023, 7:10pm UTC](https://discourse.getdbt.com/t/how-can-i-add-model-configuration-using-a-macro-on-this-in-dbt-project-yml/5910 "2023-01-04T19:10:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ludovic.gayet](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/ludovic.gayet/32/1542_2.png) [@ludovic.gayet](https://discourse.getdbt.com/u/ludovic.gayet)\
**Post date:** [January 4, 2023, 7:10pm UTC](https://discourse.getdbt.com/t/how-can-i-add-model-configuration-using-a-macro-on-this-in-dbt-project-yml/5910/1 "2023-01-04T19:10:30Z")

</div>

I want to add node\_color to all of my dbt models based on my filename prefix to make it easier to navigate through my dbt documentation :

fact\_ =\> red  
base\_\_ =\> black.

To do so i have a macro that works well :

```auto
{% macro get_model_color(model) %}

    {% set default_color = 'blue' %}
    {% set ns = namespace(model_color=default_color) %}

    
    {% set dict_patterns = {"base__[a-z0-9_]+" : "black", "ref_[a-z0-9_]+" : "yellow", "fact_[a-z0-9_]+" : "red"} %}

    {% set re = modules.re %}

    {% for pattern, color in dict_patterns.items() %}

        {% set is_match = re.match(pattern, model.identifier, re.IGNORECASE) %}
        {% if is_match %}
            {% set ns.model_color = color %}
        {% endif %}
        
    {% endfor %}

    {{ return({'node_color': ns.model_color}) }}
{% endmacro %}

```

And i call it in my model .sql :

```auto
{{config(
    materialized = 'table',
    tags=['daily'],
    docs=get_model_color(this),
)}}

```

This works well but force me to add this line of code in all my models (and in all the new ones).

Is there a way i can define it in my dbt\_project.yml to make it available to all my models automatically?

I have tried many things like the config jinja function or this kind of code in dbt\_project.yml

```auto
    +docs:
        node_color: "{{ get_model_color(this) }}"

```

returning `Could not render {{ get_model_color(this) }}: 'get_model_color' is undefined`

But nothing seems to work

Any idea? Thanks

---

<div class="post-metadata">

**Author:** ![dsynan](https://avatars.discourse-cdn.com/v4/letter/d/d78d45/32.png) [@dsynan](https://discourse.getdbt.com/u/dsynan)\
**Post date:** [November 10, 2023, 5:21pm UTC](https://discourse.getdbt.com/t/how-can-i-add-model-configuration-using-a-macro-on-this-in-dbt-project-yml/5910/2 "2023-11-10T17:21:25Z")

</div>

@ludovic.gayet Did you ever figure this out? I am running into similar issue
