<p>Craft should actually output absolute URLs when using <code>getUrl</code>. But you need to set <code>siteUrl</code> to make this work, so check if you have it set in Settings → General or with a <code>siteUrl</code> property in your general.php config file.</p>

CC BY-SA 3.0
2015-05-26T17:35:54.057Z
Thanks! My issue is that changing the siteUrl has the potential to create a variety of other issues across the site and I only want this particular rule to output the complete URL. Is there a different way that I can get http://'www.mydomain.com/ to show up in front of the root relative output of my getURL? Maybe by adding some fixed text in front of the rule in some way? Any additional guidance would be much appreciated!
dpayne
CC BY-SA 3.0
2015-05-26T17:40:56.567Z
Sure, but I would highly recommend to refactor all the code and set siteUrl to your actual domain. Probably not that much work! Anyways, you could always prepend any text with twig like so: `{% set sharingImageURL = 'http://example.com' ~ entry.sharingImage[0].getUrl('socialMedia') %}`.
carlcs
CC BY-SA 3.0
2015-05-23T16:55:30.643Z
2015-05-23T16:55:30.643Z
carlcs
<p>I'm using <code>getURL()</code> as follows in my Craft template:</p>

<pre><code>{% set sharingImageURL = entry.sharingImage[0].getUrl('socialMedia') %} 
</code></pre>

<p>Every time the output is a root relative URL and I'd like it to be a complete URL (including <code>http://www.mydomain.com</code>).</p>

<p>I can't figure out how to make that work. Can I do it with <code>getURL()</code> or is there a different method I should be using? Would appreciate some guidance!</p>

<p>Thanks.</p>

<url>
How to Make getURL Output Complete URL (rather than root relative)
# How to Make getURL Output Complete URL (rather than root relative)

(Asked by: username_0 on 2015-05-22)

I'm using getURL() as follows in my Craft template:
{% set sharingImageURL = entry.sharingImage[0].getUrl('socialMedia') %} 

Every time the output is a root relative URL and I'd like it to be a complete URL (including http://www.mydomain.com).
I can't figure out how to make that work. Can I do it with getURL() or is there a different method I should be using? Would appreciate some guidance!
Thanks.

**Tags:** url


---

## 1 answers

### Answer by username_1 on 2015-05-23. Score: 3 | Accepted answer

Craft should actually output absolute URLs when using `getUrl`. But you need to set `siteUrl` to make this work, so check if you have it set in Settings → General or with a `siteUrl` property in your general.php config file.

> **Comments:**
> **username_0**: Thanks! My issue is that changing the siteUrl has the potential to create a variety of other issues across the site and I only want this particular rule to output the complete URL. Is there a different way that I can get http://'www.mydomain.com/ to show up in front of the root relative output of my getURL? Maybe by adding some fixed text in front of the rule in some way? Any additional guidance would be much appreciated!  
> **username_1**: Sure, but I would highly recommend to refactor all the code and set siteUrl to your actual domain. Probably not that much work! Anyways, you could always prepend any text with twig like so: `{% set sharingImageURL = 'http://example.com' ~ entry.sharingImage[0].getUrl('socialMedia') %}`.  

---

