<p>I want to use one template on several Craft websites (different installations, not multi-sites). Is there a way in Craft I can do something like this? I want to update/overwrite the /templates/core/ directory when I implement new features/elements in the template but on the other hand, I want to have the option, to overwrite single template-files without losing the changes with the next update.</p>

<p>A directory structure could look like this:</p>

<ul>
<li>templates/core/layout.twig </li>
<li>templates/core/home.twig</li>
<li>template/custom/home.twig</li>
</ul>

<p>Thank you!</p>

<p><strong>UPDATE:</strong></p>

<p>One possible way would be this:</p>

<p><strong>templates/core/home.twig</strong></p>

<pre><code>{% include ['custom/home.twig', 'core/base/home.twig'] %}
</code></pre>

<p><strong>templates/core/base/home.twig</strong></p>

<pre><code>Welcome!
</code></pre>

<p><strong>templates/custom/home.twig</strong></p>

<pre><code>Willkommen!
</code></pre>

<p>Problem: For this approach, I would always need to create one file, which just calls this include. As I want to split down the template in a lot of small files, to have the option to overwrite the templates on a very low level, this would cause in maybe hundred extra files. </p>

<p>Is there anyway to do something like this:</p>

<p><strong>templates/core/home.twig</strong></p>

<pre><code>{% includeOr 'custom/home.twig' %}
   Welcome!
{% endIncludeOr%}
</code></pre>

<p><strong>templates/custom/home.twig</strong></p>

<pre><code>Willkommen!
</code></pre>

CC BY-SA 4.0
2020-05-09T12:54:59.957Z
Not sure I understand this properly but if I do, watch this video (in full) - https://vimeo.com/295001383
Oli
CC BY-SA 4.0
2020-05-11T08:24:25.737Z
This a very "open" question, but generally speaking you can get a lot by dynamically including templates - either storing the template name in a Craft field and/or checking if  a custom template exists before falling back to the core template.
gioppe
CC BY-SA 4.0
2020-05-11T12:47:18.803Z
Thanks for the video @Oli. Will watch this!
rakete
CC BY-SA 4.0
2020-05-11T12:57:19.800Z
@gioppe, I think what you describe, is exactly what I want to archive. I want to check, if there is a templates/custom/home.twig file. If yes: Load it, if not: load templates/core/home.twig. With twig's include its possible to check, if file X exists, otherwise use Y. But this brings another problem (please see my update).
rakete
<templating><craft3>
Overwrite template-files
# Overwrite template-files

(Asked by: username_0 on 2020-05-09)

I want to use one template on several Craft websites (different installations, not multi-sites). Is there a way in Craft I can do something like this? I want to update/overwrite the /templates/core/ directory when I implement new features/elements in the template but on the other hand, I want to have the option, to overwrite single template-files without losing the changes with the next update.
A directory structure could look like this:

templates/core/layout.twig 
templates/core/home.twig
template/custom/home.twig

Thank you!
UPDATE:
One possible way would be this:
templates/core/home.twig
{% include ['custom/home.twig', 'core/base/home.twig'] %}

templates/core/base/home.twig
Welcome!

templates/custom/home.twig
Willkommen!

Problem: For this approach, I would always need to create one file, which just calls this include. As I want to split down the template in a lot of small files, to have the option to overwrite the templates on a very low level, this would cause in maybe hundred extra files. 
Is there anyway to do something like this:
templates/core/home.twig
{% includeOr 'custom/home.twig' %}
   Welcome!
{% endIncludeOr%}

templates/custom/home.twig
Willkommen!

**Tags:** templating, craft3

> **Comments:**
> **username_1**: Not sure I understand this properly but if I do, watch this video (in full) - https://vimeo.com/295001383  
> **username_2**: This a very "open" question, but generally speaking you can get a lot by dynamically including templates - either storing the template name in a Craft field and/or checking if  a custom template exists before falling back to the core template.  
> **username_0**: Thanks for the video @username_1. Will watch this!  
> **username_0**: @username_2, I think what you describe, is exactly what I want to archive. I want to check, if there is a templates/custom/home.twig file. If yes: Load it, if not: load templates/core/home.twig. With twig's include its possible to check, if file X exists, otherwise use Y. But this brings another problem (please see my update).  

---

## 0 answers

