asset_url

All the asset files uploaded in the asset folder can be accessed through the asset_url variable (checkout Theme File Structure for more information)

example:

<link href="{{ asset_url ~ 'style.css' }}" rel="stylesheet" />
<body>

    <div class="app">
     <img src="{{ asset_url }}image.png" alt="" />   
    </div>

   <script src="{{ asset_url ~ 'main.js' }}"></script>
</body>

{{ asset_url ~ 'style.css' }} is a way of concatenating two strings in Twig

Last updated

Was this helpful?