<p>In Craft 3 this is now <code>{{ craft.app.request.absoluteUrl }}</code> — for those who land here from a search and want to avoid using the deprecation notice to update it!</p>

CC BY-SA 4.0
2020-01-27T01:45:18.173Z
Not sure if there's a more elegant way (I couldn't find anything digging around, closest was `craft.app.request.fullPath`), but this does the trick: `craft.app.request.absoluteUrl|replace('?'~craft.app.request.queryStringWithoutPath,'')`
Nate Beaty
CC BY-SA 4.0
2020-10-02T15:06:21.987Z
Try using the built in URL helper, like so `{{ url(craft.app.request.fullPath) }}` to remove the query string
Rob Hodges
CC BY-SA 4.0
2019-11-01T13:51:24.333Z
Any way to exclude query strings?
Laurence Cope
CC BY-SA 3.0
2018-04-09T21:29:02.867Z
2018-04-09T21:29:02.867Z
Nate Beaty
<p>In Craft 3 and PHP you can use <code>\Craft::$app-&gt;getRequest()-&gt;absoluteUrl</code> or <code>\Craft::$app-&gt;request-&gt;absoluteUrl</code></p>

CC BY-SA 4.0
2019-04-08T16:41:09.843Z
2019-04-08T16:41:09.843Z
André Mendonça
<p><strong>Craft 3, 4 and 5</strong></p>
<p>In Craft 3, 4 and 5 this is now <code>{{ craft.app.request.absoluteUrl }}</code> — for those who land here from a search and want to avoid using the deprecation notice to update it! (see answer from @natebeaty)</p>
<p>And in case you are looking for more options like <code>{{ craft.app.request.pathInfo }}</code> to get current url path, look up the <a href="https://docs.craftcms.com/api/v5/craft-web-request.html#public-properties" rel="nofollow noreferrer">Request class</a> for the available properties.</p>
<p><strong>Craft 2</strong></p>
<pre><code>{{ craft.request.getUrl() }}
</code></pre>
<p>or</p>
<pre><code>{{ craft.request.url }}
</code></pre>
<p>If you need to include the query string (like <code>?foo=bar</code>), this should do it:</p>
<pre><code>{{ craft.request.getHostInfo() ~ craft.request.getRequestUri() }}
</code></pre>
<p>Beyond that, <code>craft.request</code> is mapped to the <a href="https://docs.craftcms.com/api/v2/craft-httprequestvariable.html" rel="nofollow noreferrer">HttpRequestVariable class</a>, which contain a plethora of methods and properties to render information about the current request.</p>

CC BY-SA 4.0
2018-05-21T02:13:44.277Z
In Craft 2 you can use `{{ url('/page') }}` in Twig or `\Craft\UrlHelper::getUrl('/page')` in PHP to get an absolute URL for a given path.
Simon East
CC BY-SA 4.0
2016-11-10T19:34:23.847Z
2024-10-29T14:03:04.763Z
2024-10-29T14:03:04.763Z
Mats Mikkel Rummelhoff
<p>Very simple request!
All I want to do is to be able to get the full URL of the page &amp; output that in the HTML (for a 'share this page' link).<br>
Can anyone help please?
Many thanks!</p>

<siteurl>
How to output the full page URL?
# How to output the full page URL?

(Asked by: username_0 on 2016-11-10)

Very simple request!
All I want to do is to be able to get the full URL of the page & output that in the HTML (for a 'share this page' link).  
Can anyone help please?
Many thanks!

**Tags:** siteurl

---

## 3 answers

### Answer by username_5 on 2016-11-10. Score: 28 | Accepted answer

Craft 3, 4 and 5
In Craft 3, 4 and 5 this is now {{ craft.app.request.absoluteUrl }} — for those who land here from a search and want to avoid using the deprecation notice to update it! (see answer from @natebeaty)
And in case you are looking for more options like {{ craft.app.request.pathInfo }} to get current url path, look up the Request class for the available properties.
Craft 2
{{ craft.request.getUrl() }}

or
{{ craft.request.url }}

If you need to include the query string (like ?foo=bar), this should do it:
{{ craft.request.getHostInfo() ~ craft.request.getRequestUri() }}

Beyond that, craft.request is mapped to the HttpRequestVariable class, which contain a plethora of methods and properties to render information about the current request.

> **Comments:**
> **username_6**: In Craft 2 you can use `{{ url('/page') }}` in Twig or `\Craft\UrlHelper::getUrl('/page')` in PHP to get an absolute URL for a given path.  

---

### Answer by username_1 on 2018-04-09. Score: 29

In Craft 3 this is now `{{ craft.app.request.absoluteUrl }}` — for those who land here from a search and want to avoid using the deprecation notice to update it!

> **Comments:**
> **username_3**: Any way to exclude query strings?  
> **username_1**: Not sure if there's a more elegant way (I couldn't find anything digging around, closest was `craft.app.request.fullPath`), but this does the trick: `craft.app.request.absoluteUrl|replace('?'~craft.app.request.queryStringWithoutPath,'')`  
> **username_2**: Try using the built in URL helper, like so `{{ url(craft.app.request.fullPath) }}` to remove the query string  

---

### Answer by username_4 on 2019-04-08. Score: 6

In Craft 3 and PHP you can use `\Craft::$app->getRequest()->absoluteUrl` or `\Craft::$app->request->absoluteUrl`


---

