Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-27T01:45:18.173Z
Answers.Text: 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,'')`
Answers.UserDisplayName: Nate Beaty
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-02T15:06:21.987Z
Answers.Text: Try using the built in URL helper, like so `{{ url(craft.app.request.fullPath) }}` to remove the query string
Answers.UserDisplayName: Rob Hodges
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-01T13:51:24.333Z
Answers.Text: Any way to exclude query strings?
Answers.UserDisplayName: Laurence Cope
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-09T21:29:02.867Z
Answers.LastActivityDate: 2018-04-09T21:29:02.867Z
Answers.UserDisplayName: Nate Beaty
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-08T16:41:09.843Z
Answers.LastActivityDate: 2019-04-08T16:41:09.843Z
Answers.UserDisplayName: André Mendonça
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-21T02:13:44.277Z
Answers.Text: 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.
Answers.UserDisplayName: Simon East
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2016-11-10T19:34:23.847Z
Answers.LastActivityDate: 2024-10-29T14:03:04.763Z
Answers.LastEditDate: 2024-10-29T14:03:04.763Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <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>
  
Tags: <siteurl>
Title: How to output the full page URL?
ThreadText: # 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 @username_1)
  
  And in case you are looking for more options like `{{ craft.app.request.pathInfo }}` to get current url path, look up the [Request class](https://docs.craftcms.com/api/v5/craft-web-request.html#public-properties) 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](https://docs.craftcms.com/api/v2/craft-httprequestvariable.html), 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`
  
  
  ---
  
  