asset_url()

Twig function of the framework; its result is escaped like any value.

{{ asset_url(name) }}

The URL of a static asset of the theme or plugin, for a link, a video or any other file. The URL carries ?ver= with a hash of the file's content (for a file of an override or of @child/, its modification time), so browsers load a changed file anew. The result is text, escaped by Twig like any value. An unknown or invalid name is an error.

<a href="{{ asset_url('docs/price-list.pdf') }}">Price list</a>
ParameterTypeDefaultDescription
namestringrequiredPath of the asset below assets/, e.g. images/logo.svg; it may start with @child/ or with the instance's own prefix (@theme/ or @plugin/).

Returns string