<p>From the <a href="http://buildwithcraft.com/docs/localization-guide#step-7-update-your-templates" rel="nofollow">localization guide</a> - When Craft is looking for a template, it <em>first</em> sees if a template with that path exists inside a directory named after the current locale, then for the actual path provided.</p>

<p>So in your case, when you're in the <code>de</code> locale, it would look for the following templates:</p>

<ol>
<li><code>templates/de/_layouts/base.twig</code></li>
<li><code>templates/_layouts/base.twig</code></li>
</ol>

<p>and</p>

<ol>
<li><code>templates/de/_includes/header.twig</code></li>
<li><code>templates/_includes/header.twig</code></li>
</ol>

<p>etc, using the first one that exists.</p>

<p>If there's little or no difference between how the site behaves in different locales (other than the <a href="http://buildwithcraft.com/help/static-translations" rel="nofollow">translated strings</a>,) then it might not be necessary to override whole templates like that, but it's great when you need it.</p>

CC BY-SA 3.0
2015-03-01T20:00:59.403Z
I know, we should avoid in comments here of using words like "Thanks", but Thanks for clarification. Thanks to Twig, that Craft is so great to play with. Love it so far :)
Dominik Krulak
CC BY-SA 3.0
2015-03-01T18:28:45.410Z
2015-03-01T18:28:45.410Z
Mike Pepper
<p>I use regular file names for template structure from documentation for clearer understanding.</p>

<p>I have the template structure:</p>

<ul>
<li>_layouts
<ul>
<li>base.twig</li>
</ul></li>
<li>_includes
<ul>
<li>header.twig</li>
<li>body.twig</li>
<li>foot.twig</li>
</ul></li>
<li>index.twig</li>
<li>de
<ul>
<li>_includes
<ul>
<li>header.twig</li>
<li>body.twig</li>
<li>foot.twig</li>
</ul></li>
<li>index.twig</li>
</ul></li>
</ul>

<p>So for top level domain, 'index.twig' <code>extends</code> 'base.twig' and 'base.twig' <code>include</code> 'header.twig','body.twig' and 'foot.twig'. </p>

<p>For sub level domain (example.com/de), It's the same scenario as for top level domain.</p>

<p>All 'index.twig' files in all sub level domains <code>extends</code> the same file located at '_layouts/base.twig'.</p>

<p>The <code>include</code> filters look like this in my 'base.twig' template.</p>

<p><code>{% block header %}{% include '_includes/header' %}{% endblock %}
{% block body %}{% include '_includes/body' %}{% endblock %}
{% block foot %}{% include '_includes/foot' %}{% endblock %}</code></p>

<p><strong>All work great, but did I use it correctly?</strong></p>

<p>The thing that confuses me, is that I didn't have to copy '_layouts' folder with 'base.twig' file to 'de' folder, and modify paths in 'base.twig' for all <code>include</code> filters. Why is it so? Twig renders files of an active locale? </p>

<templating><filter><filesystem>
Do I use Twig filters 'include' and 'extends' for localized site correctly?
# Do I use Twig filters 'include' and 'extends' for localized site correctly?

(Asked by: username_0 on 2015-03-01)

I use regular file names for template structure from documentation for clearer understanding.

I have the template structure:

* \_layouts
  + base.twig
* \_includes
  + header.twig
  + body.twig
  + foot.twig
* index.twig
* de
  + \_includes
    - header.twig
    - body.twig
    - foot.twig
  + index.twig

So for top level domain, 'index.twig' `extends` 'base.twig' and 'base.twig' `include` 'header.twig','body.twig' and 'foot.twig'.

For sub level domain (example.com/de), It's the same scenario as for top level domain.

All 'index.twig' files in all sub level domains `extends` the same file located at '\_layouts/base.twig'.

The `include` filters look like this in my 'base.twig' template.

`{% block header %}{% include '_includes/header' %}{% endblock %}
{% block body %}{% include '_includes/body' %}{% endblock %}
{% block foot %}{% include '_includes/foot' %}{% endblock %}`

**All work great, but did I use it correctly?**

The thing that confuses me, is that I didn't have to copy '\_layouts' folder with 'base.twig' file to 'de' folder, and modify paths in 'base.twig' for all `include` filters. Why is it so? Twig renders files of an active locale?

**Tags:** templating, filter, filesystem


---

## 1 answers

### Answer by username_1 on 2015-03-01. Score: 3 | Accepted answer

From the [localization guide](http://buildwithcraft.com/docs/localization-guide#step-7-update-your-templates) - When Craft is looking for a template, it *first* sees if a template with that path exists inside a directory named after the current locale, then for the actual path provided.

So in your case, when you're in the `de` locale, it would look for the following templates:

1. `templates/de/_layouts/base.twig`
2. `templates/_layouts/base.twig`

and

1. `templates/de/_includes/header.twig`
2. `templates/_includes/header.twig`

etc, using the first one that exists.

If there's little or no difference between how the site behaves in different locales (other than the [translated strings](http://buildwithcraft.com/help/static-translations),) then it might not be necessary to override whole templates like that, but it's great when you need it.

> **Comments:**
> **username_0**: I know, we should avoid in comments here of using words like "Thanks", but Thanks for clarification. Thanks to Twig, that Craft is so great to play with. Love it so far :)  

---

