Answers.Body: <p>You can create localized template files by placing them in a subfolder of templates/ named after the site handle.</p>
  
  <p>See <a href="https://docs.craftcms.com/v3/dev/#template-localization" rel="nofollow noreferrer">https://docs.craftcms.com/v3/dev/#template-localization</a> for a full explanation.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-14T17:23:40.687Z
Answers.Text: Can't believe I missed this default behaviour. Thanks!
Answers.UserDisplayName: mijewe
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-14T15:46:00.563Z
Answers.LastActivityDate: 2018-12-14T15:46:00.563Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>So I've got a multisite going on.</p>
  
  <p>For most of the sites, most of the time, they'll be using the same templates. But I want a good way to handle siteX needing one template to be different from the other sites.</p>
  
  <p>For example, when going to siteX.com/news, I'd like for the template served to be siteX/news.html if it exists, otherwise default/news.html.</p>
  
  <p>I know I could change the template path in the DB, but I'd rather keep it in the code for development/deployment simplicity.</p>
  
  <p>I think I could could create custom routes, but I'd rather not create a route for <em>every</em> section.</p>
  
  <p>At the moment I'm doing this by creating a root/news.html file, which just says
  <code>
  {% include [currentSite.handle ~ '/news', 'default/news'] %}
  </code></p>
  
  <p>but it'd be nice to not have to do this for every template I create. It also seems inefficient to do this on a template level (though I don't actually <em>know</em> this to be true).</p>
  
  <p>So the questions are:</p>
  
  <ol>
  <li>(How) can I overwrite Craft's template resolver to do what I want?</li>
  <li>Is this the best way to go about this?</li>
  </ol>
  
  <p>Thanks!</p>
  
Tags: <craft3><routes>
Title: Good way to handle multisite fallback templates
ThreadText: # Good way to handle multisite fallback templates
  
  (Asked by: username_0 on 2018-12-14)
  
  So I've got a multisite going on.
  
  For most of the sites, most of the time, they'll be using the same templates. But I want a good way to handle siteX needing one template to be different from the other sites.
  
  For example, when going to siteX.com/news, I'd like for the template served to be siteX/news.html if it exists, otherwise default/news.html.
  
  I know I could change the template path in the DB, but I'd rather keep it in the code for development/deployment simplicity.
  
  I think I could could create custom routes, but I'd rather not create a route for *every* section.
  
  At the moment I'm doing this by creating a root/news.html file, which just says
  `{% include [currentSite.handle ~ '/news', 'default/news'] %}`
  
  but it'd be nice to not have to do this for every template I create. It also seems inefficient to do this on a template level (though I don't actually *know* this to be true).
  
  So the questions are:
  
  1. (How) can I overwrite Craft's template resolver to do what I want?
  2. Is this the best way to go about this?
  
  Thanks!
  
  **Tags:** craft3, routes
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-12-14. Score: 3 | Accepted answer
  
  You can create localized template files by placing them in a subfolder of templates/ named after the site handle.
  
  See <https://docs.craftcms.com/v3/dev/#template-localization> for a full explanation.
  
  > **Comments:**
  > **username_0**: Can't believe I missed this default behaviour. Thanks!  
  
  ---
  
  