# URL Twig functions

- [`ibexa_path()`](#ibexa_path) returns the absolute path to a content item or location.
- [`ibexa_url()`](#ibexa_url) returns the absolute URL to a content item or location.
- [`ibexa.url.alias`](#ibexaurlalias) generates URLs for a location from the given arguments.
- [`ibexa_route()`](#ibexa_route) generates a RouteReference object from the given parameters.
- [`ibexa_oauth2_connect_path()`](#ibexa_oauth2_connect_path) generates a relative path for the given OAuth2 route.
- [`ibexa_oauth2_connect_url()`](#ibexa_oauth2_connect_url) generates an absolute URL for the given OAuth2 route.

## URLs

### `ibexa_path()`

`ibexa_path()` returns the absolute path to a content item or location.

| Argument     | Type                                                                                                                                                                                                                                                                                                | Description                                  |
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
| `name`       | ``` string``Ibexa\Contracts\Core\Repository\Values\Content\Location``Ibexa\Contracts\Core\Repository\Values\Content\Content``Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo``Ibexa\Contracts\Core\Repository\Values\Content\Location``Ibexa\Core\MVC\Symfony\Routing\RouteReference ``` | The name of the route, location, or content. |
| `parameters` | `array`                                                                                                                                                                                                                                                                                             | Route parameters.                            |
| `relative`   | `boolean`                                                                                                                                                                                                                                                                                           | Whether to generate a relative path.         |

```
{{ ibexa_path(location) }}
```

### `ibexa_url()`

`ibexa_url()` returns the absolute URL to a content item or location.

| Argument         | Type                                                                                                                                                                                                                                                                                                | Description                                  |
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
| `name`           | ``` string``Ibexa\Contracts\Core\Repository\Values\Content\Location``Ibexa\Contracts\Core\Repository\Values\Content\Content``Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo``Ibexa\Contracts\Core\Repository\Values\Content\Location``Ibexa\Core\MVC\Symfony\Routing\RouteReference ``` | The name of the route, location, or content. |
| `parameters`     | `array`                                                                                                                                                                                                                                                                                             | Route parameters.                            |
| `schemeRelative` | `boolean`                                                                                                                                                                                                                                                                                           | Whether to generate a relative URL.          |

```
{{ ibexa_url(location, {}, false) }}
```

### `ibexa.url.alias`

`ibexa.url.alias` generates URLs for a Location from the given parameters.

Note

`ibexa.url.alias` is a not a Twig function, but a special route name.

For more information about the use of `ibexa.url.alias` as a parameter of the [Symfony `path` Twig function](https://symfony.com/doc/7.4/reference/twig_reference.html#path), see [Links to other locations](https://doc.ibexa.co/en/latest/templating/urls_and_routes/urls_and_routes/index.md).

```
{% set href = path('ibexa.url.alias', { 'locationId': 2 }) %}
```

### `ibexa_route()`

`ibexa_route()` generates a [RouteReference object](https://doc.ibexa.co/en/latest/templating/urls_and_routes/urls_and_routes/#routereference) from the given parameters.

| Argument   | Type                                                                                                                                                                                                                                                                                                | Description             |
| ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- |
| `resource` | ``` string``Ibexa\Contracts\Core\Repository\Values\Content\Location``Ibexa\Contracts\Core\Repository\Values\Content\Content``Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo``Ibexa\Contracts\Core\Repository\Values\Content\Location``Ibexa\Core\MVC\Symfony\Routing\RouteReference ``` | Resource or route name. |
| `params`   | `array`                                                                                                                                                                                                                                                                                             | Route parameters.       |

```
{% set routeReference = ibexa_route("ibexa.url.alias", { 'locationId': 2 }) %}
```

## OAuth2

### `ibexa_oauth2_connect_path()`

`ibexa_oauth2_connect_path()` generates a relative path for the given [OAuth2 client](https://doc.ibexa.co/en/latest/users/oauth_client/index.md).

| Argument     | Type      | Description                          |
| ------------ | --------- | ------------------------------------ |
| `identifier` | string    | Identifier of the OAuth connection.  |
| `parameters` | `array`   | Route parameters.                    |
| `relative`   | `boolean` | Whether to generate a relative path. |

### `ibexa_oauth2_connect_url()`

`ibexa_oauth2_connect_url()` generates an absolute URL for the given [OAuth2 client](https://doc.ibexa.co/en/latest/users/oauth_client/index.md).

| Argument         | Type      | Description                         |
| ---------------- | --------- | ----------------------------------- |
| `identifier`     | string    | Identifier of the OAuth connection. |
| `parameters`     | `array`   | Route parameters.                   |
| `schemeRelative` | `boolean` | Whether to generate a relative URL. |
