Answers.Body: <p>The shortest way, still checking if the parent exists, is to use (not tested):</p>
  
  <pre><code>{{ entry.parent ? entry.parent.link }}
  </code></pre>
  
  <p><a href="http://buildwithcraft.com/docs/templating/entrymodel#link"><code>entry.link</code></a>, or <code>entry.getLink()</code> gives you the <code>&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;</code> part.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-02T15:31:15.957Z
Answers.Text: wonderful > {{ entry.parent.url }} was all i'm looking for
Answers.UserDisplayName: eek-a-edge
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-02T15:04:57.863Z
Answers.LastActivityDate: 2014-10-02T15:04:57.863Z
Answers.UserDisplayName: Paul
Body: <p>Is there a tag that can shorten the following:</p>
  
  <pre><code>{% set parentPage = entry.getParent() %}
  {% if parentPage %} &lt;a href="{{ parentPage.url }}"&gt;{{ parentPage.title }}&lt;/a&gt;
  {% endif %}
  </code></pre>
  
  <p>Something like <code>{entry.getParentUrl}</code>?</p>
  
Tags: <templating><url>
Title: Is there a tag to get the parents url like {{entry.url}}?
ThreadText: # Is there a tag to get the parents url like {{entry.url}}?
  
  (Asked by: username_0 on 2014-10-02)
  
  Is there a tag that can shorten the following:
  
  ```
  {% set parentPage = entry.getParent() %}
  {% if parentPage %} <a href="{{ parentPage.url }}">{{ parentPage.title }}</a>
  {% endif %}
  
  ```
  
  Something like `{entry.getParentUrl}`?
  
  **Tags:** templating, url
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-10-02. Score: 10 | Accepted answer
  
  The shortest way, still checking if the parent exists, is to use (not tested):
  
  ```
  {{ entry.parent ? entry.parent.link }}
  
  ```
  
  [`entry.link`](http://buildwithcraft.com/docs/templating/entrymodel#link), or `entry.getLink()` gives you the `<a href="{{ entry.url }}">{{ entry.title }}</a>` part.
  
  > **Comments:**
  > **username_0**: wonderful > {{ entry.parent.url }} was all i'm looking for  
  
  ---
  
  