<p>You can slice the / from the end of {{ siteUrl }} and combine it with getUrl relative path:</p>

<pre><code>&lt;meta property="og:image" content="{{ siteUrl|slice(0,-1) }}{{ entry.fieldName.one().getUrl('kafel620') }}"&gt;
</code></pre>

<p>This will produce expected path:</p>

<pre><code>&lt;meta property="og:image" content="http://site.local/assets/images/ramPamPam/headers/_kafel620/tagiatelle.jpg"&gt;
</code></pre>

CC BY-SA 4.0
2018-05-30T09:10:12.527Z
2018-05-30T09:10:12.527Z
denesis
<blockquote>
  <p>Prepending it with <code>{{ siteURL }}</code> creates two <code>/</code>'s e.g.  <code>http://sitename.test//asseturl.jpg</code></p>
</blockquote>

<p>It would do that if you've defined your site URL (either in Settings->Sites->Base URL or using the <code>CRAFT_SITE</code> PHP constant) with a trailing slash at the end of it.</p>

<p>i.e. <code>http://sitename.test/</code></p>

<p>Changing it to <code>http://sitename.test</code> would work.</p>

CC BY-SA 4.0
2018-05-10T14:01:00.937Z
Thanks @Brad Bell - however using the `@web` alias forces a trailing slash upon saving the site settings page. Presumably I would have to set the URL explicitly to avoid this.
Adam Menczykowski
CC BY-SA 4.0
2018-05-10T14:01:54.033Z
Also, explicitly setting the domain name in Site config also forces a trailing slash on save
Adam Menczykowski
CC BY-SA 3.0
2018-02-17T21:21:58.250Z
2018-02-17T21:21:58.250Z
Brad Bell
<p>I'm trying to output the full asset URL. Using Craft 3.0.0-RC7.1</p>

<p>In <code>.env</code>:</p>

<pre><code>ASSETS_BASE_PATH=/Users/user/code/sitename/web
ASSETS_BASE_URL=http://sitename.test
</code></pre>

<p>In <code>config/volumes.php</code>:</p>

<pre><code>'siteAssets' =&gt; [
    'path' =&gt; getenv('ASSETS_BASE_PATH') . '/assets/images',
    'url' =&gt; getenv('ASSETS_BASE_URL') . '/assets/images',
],
</code></pre>

<p>In my template:</p>

<pre><code>&lt;meta property="og:image" content="
{{ entry.socialSharingImage.one.getUrl('socialSharing') }}
" /&gt;
</code></pre>

<p>Output:</p>

<pre><code>&lt;meta property="og:image" content="
/index.php?p=actions/assets/generate-transform&amp;amp;transformId=58"&gt;
</code></pre>

<p>As you see, no site url at the start. Any ideas?</p>

<p>It seems the <code>getUrl()</code> method returns the path. Prepending it with <code>{{ siteURL }}</code> creates two <code>/</code>'s e.g. <code>http://sitename.test//asseturl.jpg</code>. Same results in dev and production.</p>

<p>Thanks!</p>

<craft3>
Get full url of asset, not just the path
# Get full url of asset, not just the path

(Asked by: username_0 on 2018-02-16)

I'm trying to output the full asset URL. Using Craft 3.0.0-RC7.1
In .env:
ASSETS_BASE_PATH=/Users/user/code/sitename/web
ASSETS_BASE_URL=http://sitename.test

In config/volumes.php:
'siteAssets' => [
    'path' => getenv('ASSETS_BASE_PATH') . '/assets/images',
    'url' => getenv('ASSETS_BASE_URL') . '/assets/images',
],

In my template:


Output:


As you see, no site url at the start. Any ideas?
It seems the getUrl() method returns the path. Prepending it with {{ siteURL }} creates two /'s e.g. http://sitename.test//asseturl.jpg. Same results in dev and production.
Thanks!

**Tags:** craft3


---

## 2 answers

### Answer by username_1 on 2018-05-30. Score: 3

You can slice the / from the end of {{ siteUrl }} and combine it with getUrl relative path:


This will produce expected path:


---

### Answer by username_2 on 2018-02-17. Score: 1

> Prepending it with `{{ siteURL }}` creates two `/`'s e.g. `http://sitename.test//asseturl.jpg`

It would do that if you've defined your site URL (either in Settings->Sites->Base URL or using the `CRAFT_SITE` PHP constant) with a trailing slash at the end of it.

i.e. `http://sitename.test/`

Changing it to `http://sitename.test` would work.

> **Comments:**
> **username_0**: Thanks @username_2 - however using the `@web` alias forces a trailing slash upon saving the site settings page. Presumably I would have to set the URL explicitly to avoid this.  
> **username_0**: Also, explicitly setting the domain name in Site config also forces a trailing slash on save  

---

