<p>They do the same thing. <code>url()</code> is an alias of <code>getUrl()</code>. This is the link from the Craft 2 docs: <a href="https://docs.craftcms.com/v2/templating/entrymodel.html#url" rel="nofollow noreferrer">https://docs.craftcms.com/v2/templating/entrymodel.html#url</a>.</p>
<p>It works the same way in Craft 3, but I can never find anything in the Craft 3 docs.</p>

CC BY-SA 4.0
2020-06-24T14:43:44.703Z
2020-06-24T14:43:44.703Z
darylknight
<p>What is the different between url() and getUrl()</p>
<p>Ex:</p>
<pre><code>   {% set solutionIcon = solution.solutionIcon.one() ?? null %}
   &lt;div class=&quot;img-wrapper mt--3 mb-2 mx-auto&quot;&gt;
      {% if solutionIcon %}
         &lt;img src=&quot;{{ solutionIcon.getUrl() }}&quot; alt=&quot;{{ solutionIcon.title }}&quot;&gt;
      {% endif %}
   &lt;/div&gt;

   {% set solutionIcon = solution.solutionIcon.one() ?? null %}
   &lt;div class=&quot;img-wrapper mt--3 mb-2 mx-auto&quot;&gt;
      {% if solutionIcon %}
         &lt;img src=&quot;{{ solutionIcon.url() }}&quot; alt=&quot;{{ solutionIcon.title }}&quot;&gt;
      {% endif %}
   &lt;/div&gt;
</code></pre>

<url>
What is the different between url() and getUrl()
# What is the different between url() and getUrl()

(Asked by: username_0 on 2020-06-24)

What is the different between url() and getUrl()
Ex:
   {% set solutionIcon = solution.solutionIcon.one() ?? null %}
   
      {% if solutionIcon %}
         
      {% endif %}
   

   {% set solutionIcon = solution.solutionIcon.one() ?? null %}
   
      {% if solutionIcon %}
         
      {% endif %}

**Tags:** url


---

## 1 answers

### Answer by username_1 on 2020-06-24. Score: 1

They do the same thing. `url()` is an alias of `getUrl()`. This is the link from the Craft 2 docs: <https://docs.craftcms.com/v2/templating/entrymodel.html#url>.

It works the same way in Craft 3, but I can never find anything in the Craft 3 docs.


---

