<p>Instead of <code>{{siteUrl}}{{entry.ogImage.first().url}}</code>, try <code>{{entry.ogImage.first().getUrl()}}</code>. <a href="https://craftcms.com/classreference/models/AssetFileModel#getUrl-detail" rel="nofollow">getUrl()</a> should return the full image path, including host.</p>

CC BY-SA 3.0
2016-09-19T21:10:58.487Z
2016-09-19T21:10:58.487Z
Aaron Berkowitz
<p>so I'm using an asset field for an OG Image. I need to get the full url for this and I've yet to find a clean way to do this. I figured I could just combine siteUrl and the asset url but I have a weird issue with a double slash. </p>

<pre><code>&lt;meta property="og:image" content="{{siteUrl}}{{entry.ogImage.first().url}}/&gt;
</code></pre>

<p>This does what I expect except it adds a slash at the end of {{siteUrl}} and the beginning of the asset so my url is bad, leaving me with a double slash. Short of some programatical removal of the slash, is there another way to do this? Why does my siteUrl have that trailing slash? is something wrong there? </p>

<config><siteurl>
Get full file url, avoiding the siteUrl trailing slash
# Get full file url, avoiding the siteUrl trailing slash

(Asked by: username_0 on 2016-09-19)

so I'm using an asset field for an OG Image. I need to get the full url for this and I've yet to find a clean way to do this. I figured I could just combine siteUrl and the asset url but I have a weird issue with a double slash. 
<meta property="og:image" content="{{siteUrl}}{{entry.ogImage.first().url}}/>

This does what I expect except it adds a slash at the end of {{siteUrl}} and the beginning of the asset so my url is bad, leaving me with a double slash. Short of some programatical removal of the slash, is there another way to do this? Why does my siteUrl have that trailing slash? is something wrong there?

**Tags:** config, siteurl


---

## 1 answers

### Answer by username_1 on 2016-09-19. Score: 2

Instead of `{{siteUrl}}{{entry.ogImage.first().url}}`, try `{{entry.ogImage.first().getUrl()}}`. [getUrl()](https://craftcms.com/classreference/models/AssetFileModel#getUrl-detail) should return the full image path, including host.


---

