<p>Try LinkIt. Allows you to set attributes.
<a href="https://github.com/fruitstudios/LinkIt/blob/master/README.md" rel="nofollow">https://github.com/fruitstudios/LinkIt/blob/master/README.md</a></p>

CC BY-SA 3.0
2016-09-21T22:57:14.383Z
2016-09-21T22:57:14.383Z
shorn
<p>No, <code>getLink</code> outputs a very simple version of the link.</p>

<p>If you want something more complex, you'll need to build it manually...</p>

<pre><code>&lt;a href="{{ foo.url }}" class="bar"&gt;{{ foo.title }}&lt;/a&gt;
</code></pre>

CC BY-SA 3.0
2016-09-14T03:31:55.903Z
2016-09-14T03:31:55.903Z
Lindsey D
<p>This code: </p>

<pre><code>{{ foo.getLink() }}
</code></pre>

<p>Outputs this:</p>

<pre><code>&lt;a href="URL_HERE"&gt;NAME_OF_PAGE&lt;/a&gt;
</code></pre>

<p>What I really want is something like:</p>

<pre><code>&lt;a href="URL_HERE" class="bar"&gt;NAME_OF_PAGE&lt;/a&gt;
</code></pre>

<p>Is it possible to set "class" and/or other html attributes when using Craft CMS Entry Property <a href="https://craftcms.com/docs/templating/entrymodel#getLink" rel="nofollow">getLink()</a>?</p>

<templating><link>
Is it possible to set any attributes (such as a class) of the `a` tag when using `getLink()`?
# Is it possible to set any attributes (such as a class) of the `a` tag when using `getLink()`?

(Asked by: username_0 on 2016-09-14)

This code: 
{{ foo.getLink() }}

Outputs this:
NAME_OF_PAGE

What I really want is something like:
NAME_OF_PAGE

Is it possible to set "class" and/or other html attributes when using Craft CMS Entry Property getLink()?

**Tags:** templating, link


---

## 2 answers

### Answer by username_2 on 2016-09-14. Score: 9 | Accepted answer

No, getLink outputs a very simple version of the link.
If you want something more complex, you'll need to build it manually...
{{ foo.title }}


---

### Answer by username_1 on 2016-09-21. Score: 0

Try LinkIt. Allows you to set attributes.
<https://github.com/fruitstudios/LinkIt/blob/master/README.md>


---

