Answers.Body: <p><a href="https://docs.craftcms.com/v3/dev/element-queries/entry-queries.html#parameters" rel="nofollow noreferrer">According to the <code>EntryQuery</code> documentation</a>, you can search by URI.</p>
  
  <p>The most basic use (searching by the complete URI) would look like this:</p>
  
  <pre><code>{% set entryWithUri = craft.entries({
    uri: craft.app.request.path | literal
  }).one() %}
  </code></pre>
  
  <p>But to progressively dive into the segments (say, to create breadcrumbs like you mentioned), it takes a little more work:</p>
  
  <pre><code>{% set segments = craft.app.request.segments %}
  
  {% for segment in segments %}
    {% set uriPart = segments[0:loop.index] %}
  
    {% set entryAtPath = craft.entries({
      uri: uriPart | join('/') | literal
    }).one() %}
  
    {% if entryAtPath %}
      {{ entryAtPath.link }}
    {% endif %}
  {% endfor %}
  </code></pre>
  
  <p>Supposing <code>entryAtPath</code> is empty, you may then need to fall back to a Category query, then a Tag query, etc. Unfortunately, there isn't a great way to fetch across Element types—which would make this a little easier.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-20T23:48:36.427Z
Answers.Text: Great piece of code, thanks! I will be using it in my boilerplate template from now on. I would only change one thing - to decrease number of queries, i would add `if not loop.last` - last part of breadcrumb is always current category/entry so there is no need for query. One question - what does literal filter do in this situation?
Answers.UserDisplayName: Piotr Pogorzelski
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-20T20:55:23.840Z
Answers.LastActivityDate: 2018-11-20T20:55:23.840Z
Answers.UserDisplayName: August Miller
Answers.Body: <p>Usually I have a {{baseUrl}} defined in config or .env available globally;
  then {{baseUrl}}/{{entry.uri}}</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-19T21:10:53.067Z
Answers.Text: I think the question is about how to _look up_ an entry by a full URI, not how to get the complete path/URI of an entry.
Answers.UserDisplayName: August Miller
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-20T19:07:47.700Z
Answers.Text: Yeas, thats what i want to do @AugustMiller
Answers.UserDisplayName: Piotr Pogorzelski
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-19T15:08:51.807Z
Answers.LastActivityDate: 2018-11-19T15:08:51.807Z
Answers.UserDisplayName: joomkit
Body: <p>Can I resolve full URL to some object - entry or category, from inside Twig template?</p>
  
  <p>Mind you, I don't mean searching for something by slug, but by full URL. So, for example, instead of passing <code>'some-slug'</code> to function, i want to pass <code>'some-category/some-subcategory/some-slug'</code>.</p>
  
  <p>I need to to this, because i want to create breadcrumbs links based on <code>craft.request.segments</code> object. So, i need to look up for entry object for <code>some-category</code>, then entry for <code>some-category/some-subcategory/</code> and then for <code>some-category/some-subcategory/some-slug</code> (well, i dont really need last one because its just page im on currently).</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-11-19T21:13:04.083Z
Comments.Text: In most cases, Craft does this for you, and you'll have access to `{{ entry }}`, `{{ category }}`, etc. in your template, already. Where is this URI coming from?
Comments.UserDisplayName: August Miller
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-11-20T19:04:06.107Z
Comments.Text: I want to create breadcrumb links based on request segments.
Comments.UserDisplayName: Piotr Pogorzelski
Tags: <url>
Title: Resolve url from inside template
ThreadText: # Resolve url from inside template
  
  (Asked by: username_0 on 2018-11-18)
  
  Can I resolve full URL to some object - entry or category, from inside Twig template?
  
  Mind you, I don't mean searching for something by slug, but by full URL. So, for example, instead of passing `'some-slug'` to function, i want to pass `'some-category/some-subcategory/some-slug'`.
  
  I need to to this, because i want to create breadcrumbs links based on `craft.request.segments` object. So, i need to look up for entry object for `some-category`, then entry for `some-category/some-subcategory/` and then for `some-category/some-subcategory/some-slug` (well, i dont really need last one because its just page im on currently).
  
  **Tags:** url
  
  > **Comments:**
  > **username_1**: In most cases, Craft does this for you, and you'll have access to `{{ entry }}`, `{{ category }}`, etc. in your template, already. Where is this URI coming from?  
  > **username_0**: I want to create breadcrumb links based on request segments.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-11-20. Score: 0 | Accepted answer
  
  [According to the `EntryQuery` documentation](https://docs.craftcms.com/v3/dev/element-queries/entry-queries.html#parameters), you can search by URI.
  
  The most basic use (searching by the complete URI) would look like this:
  
  ```
  {% set entryWithUri = craft.entries({
    uri: craft.app.request.path | literal
  }).one() %}
  
  ```
  
  But to progressively dive into the segments (say, to create breadcrumbs like you mentioned), it takes a little more work:
  
  ```
  {% set segments = craft.app.request.segments %}
  
  {% for segment in segments %}
    {% set uriPart = segments[0:loop.index] %}
  
    {% set entryAtPath = craft.entries({
      uri: uriPart | join('/') | literal
    }).one() %}
  
    {% if entryAtPath %}
      {{ entryAtPath.link }}
    {% endif %}
  {% endfor %}
  
  ```
  
  Supposing `entryAtPath` is empty, you may then need to fall back to a Category query, then a Tag query, etc. Unfortunately, there isn't a great way to fetch across Element types—which would make this a little easier.
  
  > **Comments:**
  > **username_0**: Great piece of code, thanks! I will be using it in my boilerplate template from now on. I would only change one thing - to decrease number of queries, i would add `if not loop.last` - last part of breadcrumb is always current category/entry so there is no need for query. One question - what does literal filter do in this situation?  
  
  ---
  
  ### Answer by username_2 on 2018-11-19. Score: 0
  
  Usually I have a {{baseUrl}} defined in config or .env available globally;
  then {{baseUrl}}/{{entry.uri}}
  
  > **Comments:**
  > **username_1**: I think the question is about how to _look up_ an entry by a full URI, not how to get the complete path/URI of an entry.  
  > **username_0**: Yeas, thats what i want to do @username_1  
  
  ---
  
  