> For the complete documentation index, see [llms.txt](https://docs.strata.dev/frontend/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.strata.dev/frontend/development/urls.md).

# URLs

You can setup URLs in your PHP controller code via the `Url` object.

To create a new URL with the pattern `news/:slug`:

```
$url = new Url('news/:slug');
```

When combined with a content object with a URL slug of `hello-world`:

```
echo $url->getUrl($content);
```

Returns: `news/hello-world`

You can also output the URL via Twig, this outputs the URL for the current content object.

```
{{ page.url }}
```

## URL params

You can parse in content variables into the URL, using the options below.

To set a parameter the format is `:param-name`

To set options associated with the param the format is: `:param-name(option=value,option2=value)`

### id

Parse in the content ID. E.g.

```
$url = new Url('news/:id');
```

Example URL: `news/123`

### slug

Parse in the URL slug. E.g.

```
$url = new Url('news/:slug');
```

Example URL: `news/hello-world`

### date\_published

Parse in the date published slug.

By default the date is outputted in the format `Y/m/d`

```
$url = new Url('news/:date_published/:slug');
```

Example URL: `news/2019/02/12/hello-world`

You can also set the `format` option which controls how the date is outputted in the URL. See [date format](https://www.php.net/datetime.format) options.

```
$url = new Url('news/:date_published(format=Y)/:slug');
```

Example URL: `news/2019/hello-world`

### date\_modified

Parse in the date modified slug. This works in the same way as `date_published`

```
$url = new Url('news/:date_modified/:slug');
```

Example URL: `news/2019/02/13/hello-world`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.strata.dev/frontend/development/urls.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
