Answers.Body: <p>There are two issues with your code:</p>
  <ol>
  <li><p>You aren't able to reference <code>entry</code> in the field. <a href="https://craftcms.com/docs/4.x/entries.html#dynamic-entry-titles" rel="nofollow noreferrer">This section</a> in the docs describes the rules around using Twig in the Entry title field, and the same rules apply in this case as well. The long and short of it is you can either use the shortcut syntax and forego referencing the entry at all: <code>{site.slug}</code>, or you can use the normal syntax, in which case you'll want to use the <code>object</code> variable to refer to the current entry: <code>{{ object.site.slug }}</code>.</p>
  </li>
  <li><p>Secondly, Sites don't have slugs (you can see all possible variables <a href="https://docs.craftcms.com/api/v4/craft-models-site.html" rel="nofollow noreferrer">here</a>). My suggestion would be to use the Site's handle instead, and maybe throw the <a href="https://craftcms.com/docs/4.x/dev/filters.html#kebab" rel="nofollow noreferrer"><code>kebab</code> filter</a> on it so it looks better (<code>/path/to/images/my-lovely-site</code> instead of <code>/path/to/images/myLovelySite</code>):</p>
  <pre><code>{site.handle|kebab}
  
  {# or {{ object.site.handle|kebab }} #}
  </code></pre>
  </li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-14T21:18:21.703Z
Answers.Text: I pushed a page for the 5.x docs on [object templates](https://craftcms.com/docs/5.x/system/object-templates.html), but haven't back-ported it to the 4.x docset just yet!
Answers.UserDisplayName: August Miller
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-15T10:45:03.450Z
Answers.Text: Yes it works ! thank you !
Answers.UserDisplayName: emilie zawadzki
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-22T12:28:05.103Z
Answers.Text: It works but.... if you have a multilingual site, you'll have to upload two times the assets.
  So I needed to slice the last letter of my site handle (mySiteFR, mySiteEN...) which correponds to the letter of the language (FR, EN, DE...).
  Here the solution : {site.handle|kebab|substr(0,-2)}
Answers.UserDisplayName: emilie zawadzki
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-14T19:11:01.337Z
Answers.LastActivityDate: 2024-02-14T19:11:01.337Z
Answers.UserDisplayName: Jalen Davenport
Body: <p>In Craft 4.7.2.1 Pro, I try to create dynamic path location for my assets for my field &quot;image&quot;.
  The field image is in MySection, which is shared with multiple sites.</p>
  <p>I would like to organize images in separate folders for each site. I tried something like :</p>
  <pre><code>{entry.site.slug}
  </code></pre>
  <p>but doesn't work</p>
  
Tags: <assets><assets-field>
Title: Assets dynamic location functions of site
ThreadText: # Assets dynamic location functions of site
  
  (Asked by: username_0 on 2024-02-13)
  
  In Craft 4.7.2.1 Pro, I try to create dynamic path location for my assets for my field "image".
  The field image is in MySection, which is shared with multiple sites.
  
  I would like to organize images in separate folders for each site. I tried something like :
  
  ```
  {entry.site.slug}
  
  ```
  
  but doesn't work
  
  **Tags:** assets, assets-field
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-02-14. Score: 2 | Accepted answer
  
  There are two issues with your code:
  
  1. You aren't able to reference `entry` in the field. [This section](https://craftcms.com/docs/4.x/entries.html#dynamic-entry-titles) in the docs describes the rules around using Twig in the Entry title field, and the same rules apply in this case as well. The long and short of it is you can either use the shortcut syntax and forego referencing the entry at all: `{site.slug}`, or you can use the normal syntax, in which case you'll want to use the `object` variable to refer to the current entry: `{{ object.site.slug }}`.
  2. Secondly, Sites don't have slugs (you can see all possible variables [here](https://docs.craftcms.com/api/v4/craft-models-site.html)). My suggestion would be to use the Site's handle instead, and maybe throw the [`kebab` filter](https://craftcms.com/docs/4.x/dev/filters.html#kebab) on it so it looks better (`/path/to/images/my-lovely-site` instead of `/path/to/images/myLovelySite`):
  
     ```
     {site.handle|kebab}
  
     {# or {{ object.site.handle|kebab }} #}
  
     ```
  
  > **Comments:**
  > **username_2**: I pushed a page for the 5.x docs on [object templates](https://craftcms.com/docs/5.x/system/object-templates.html), but haven't back-ported it to the 4.x docset just yet!  
  > **username_0**: Yes it works ! thank you !  
  > **username_0**: It works but.... if you have a multilingual site, you'll have to upload two times the assets. So I needed to slice the last letter of my site handle (mySiteFR, mySiteEN...) which correponds to the letter of the language (FR, EN, DE...). Here the solution : {site.handle|kebab|substr(0,-2)}  
  
  ---
  
  