> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ghost.org/llms.txt
> Use this file to discover all available pages before exploring further.

# link

> Usage: `{{#link href="/about/"}}About{{/link}}`

***

`{{#link}}` is a block helper that creates links with dynamic classes. In its basic form it will create an anchor element that wraps around any kind of string, HTML or handlebars constructed HTML.

With additional options it can have an active `class` or `target` behaviour, or `onclick` JavaScript events. A `href` attribute must be included or an error will be thrown.

## Simple example

```handlebars theme={"dark"}
{{#link href="/about/"}}..linked content here..{{/link}}

Will output:

<a href="/about/">..linked content here..</a>
```

All attributes associated with the `<a></a>` element can be used in `{{#link}}`. Check out the MDN documentation on [the anchor element for more information](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a).

## Variables

Handlebars variables can be used for attribute values as well as strings. Variables do not need be wrapped with quotations:

### Simple variables example

```handlebars theme={"dark"}
{{#link href=@site.url}}Home{{/link}}
```

### Advanced variables example

```handlebars theme={"dark"}
{{#foreach posts}}
  {{#link href=(url) class="post-link" activeClass="active"}}
    {{title}}
  {{/link}}
{{/foreach}}
```

## Dynamic attributes

### `activeClass`

By default the active class outputted by `{{#link}}` will be `nav-current`, this is consistent with our [navigation helper](/themes/helpers/data/navigation/). However it can be overwritten with the `activeClass` attribute:

### `activeClass` Example

```handlebars theme={"dark"}
{{#link href="/about/" activeClass="current"}}About{{/link}}

When on the "/about/" URL it will output:

<a href="/about/" class="current">About</a>
```

`activeClass` can also be given `false` value (`activeClass=false`), which will output an empty string. Effectively turning off the behaviour.
