---
title: "init(template:variables:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/url/init(template:variables:)"
---

# init(template:variables:)

Creates a new URL by expanding the RFC 6570 template and variables.

## Declaration

```swift
init?(template: URL.Template, variables: [URL.Template.VariableName : URL.Template.Value])
```

## Parameters

- `template`: The RFC 6570 template to be expanded.
- `variables`: Variables to expand in the template.

## Discussion

Discussion This will fail if variable expansion does not produce a valid, well-formed URL. All text will be converted to NFC (Unicode Normalization Form C) and UTF-8 before being percent-encoded if needed.
