Answers.Body: <p>Welcome to Craft! Seeing as you are new I will try and explain the error, and offer some advice on how I would architect what you are trying to achieve:</p>
  
  <p><code>Variable "siteLogo" does not exist.</code></p>
  
  <p>This error <em>is</em> coming from the code sample you provided, more specifically it is referring to this part:</p>
  
  <p><code>{% for asset in siteLogo.</code></p>
  
  <p>Craft is looking for something called <code>siteLogo</code>. It's not looking for a <em>field</em> called <code>siteLogo</code>, rather a place where that field might exist.</p>
  
  <p>I would assume your asset field exists inside a <a href="https://docs.craftcms.com/v3/globals.html" rel="nofollow noreferrer">Global</a>? That's how I would do it, but you just need to double check what the handle of your Global is, as that's what you use to access it in the templates. Also double check what the handle of your asset field is, as again, that's what you use in the templates to reference that field and get the asset in it.</p>
  
  <hr>
  
  <p>So taking that, here is what I would do:</p>
  
  <p>Firstly, I would use a <a href="https://docs.craftcms.com/v3/globals.html" rel="nofollow noreferrer">Global</a>, but I wouldn't call this "Site Logo". That is too specific. Maybe call it "Branding", as this opens up the possibility of adding more fields (Colour Scheme etc).</p>
  
  <p>When you create a Global, Craft automatically generates the handle from the name you provide. A Global with a name of "Branding" would have a handle of <code>branding</code>.</p>
  
  <p>Next I would create an Asset field, and call this "Site Logo". This handle would automatically generate to <code>siteLogo</code> (what you have already). You would also want to restrict this Asset field to 1 asset.</p>
  
  <p>Now for the template.</p>
  
  <p>As you only have 1 logo you do not need to do a <code>forloop</code>. Instead you can just output the 1 asset like so:</p>
  
  <pre><code>{% set logo = branding.siteLogo.one %}
  {% if logo|length %}
      &lt;img src="{{ logo.url }}"&gt;
  {% endif %}
  </code></pre>
  
  <p>I hope that helps!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-16T08:21:35.640Z
Answers.Text: Thank you so much Jamie! Your explanation was great. I have been struggling to understand Craft but it feels good to finally make some progress. I know this is quite basic but hopefully I can start to understand more as I continue.
Answers.UserDisplayName: Jaffa
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-15T15:01:31.663Z
Answers.LastActivityDate: 2019-04-15T15:01:31.663Z
Answers.UserDisplayName: Jamie Wade
Body: <p>I am new to Craft CMS and struggling to figure out how to display my logo in my template.</p>
  
  <p>The error message is:</p>
  
  <p><code>Variable "siteLogo" does not exist</code></p>
  
  <p>This is the code I am using: </p>
  
  <pre><code>{% for asset in siteLogo.siteLogo %} 
      &lt;img width="180px" src="{{ asset.url }}" alt="ICW Logo"&gt;
  {% endfor %}
  </code></pre>
  
  <p>Any advice would be greatly appreciated!</p>
  
  <p>Thanks in advance.</p>
  
Tags: <craft3>
Title: How to display images in templates
ThreadText: # How to display images in templates
  
  (Asked by: username_0 on 2019-04-15)
  
  I am new to Craft CMS and struggling to figure out how to display my logo in my template.
  
  The error message is:
  
  `Variable "siteLogo" does not exist`
  
  This is the code I am using:
  
  ```
  {% for asset in siteLogo.siteLogo %} 
      <img width="180px" src="{{ asset.url }}" alt="ICW Logo">
  {% endfor %}
  
  ```
  
  Any advice would be greatly appreciated!
  
  Thanks in advance.
  
  **Tags:** craft3
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-04-15. Score: 4
  
  Welcome to Craft! Seeing as you are new I will try and explain the error, and offer some advice on how I would architect what you are trying to achieve:
  
  `Variable "siteLogo" does not exist.`
  
  This error *is* coming from the code sample you provided, more specifically it is referring to this part:
  
  `{% for asset in siteLogo.`
  
  Craft is looking for something called `siteLogo`. It's not looking for a *field* called `siteLogo`, rather a place where that field might exist.
  
  I would assume your asset field exists inside a [Global](https://docs.craftcms.com/v3/globals.html)? That's how I would do it, but you just need to double check what the handle of your Global is, as that's what you use to access it in the templates. Also double check what the handle of your asset field is, as again, that's what you use in the templates to reference that field and get the asset in it.
  
  ---
  
  So taking that, here is what I would do:
  
  Firstly, I would use a [Global](https://docs.craftcms.com/v3/globals.html), but I wouldn't call this "Site Logo". That is too specific. Maybe call it "Branding", as this opens up the possibility of adding more fields (Colour Scheme etc).
  
  When you create a Global, Craft automatically generates the handle from the name you provide. A Global with a name of "Branding" would have a handle of `branding`.
  
  Next I would create an Asset field, and call this "Site Logo". This handle would automatically generate to `siteLogo` (what you have already). You would also want to restrict this Asset field to 1 asset.
  
  Now for the template.
  
  As you only have 1 logo you do not need to do a `forloop`. Instead you can just output the 1 asset like so:
  
  ```
  {% set logo = branding.siteLogo.one %}
  {% if logo|length %}
      <img src="{{ logo.url }}">
  {% endif %}
  
  ```
  
  I hope that helps!
  
  > **Comments:**
  > **username_0**: Thank you so much username_1! Your explanation was great. I have been struggling to understand Craft but it feels good to finally make some progress. I know this is quite basic but hopefully I can start to understand more as I continue.  
  
  ---
  
  