asset_url Filter

Returns the URL of an asset within the theme’s assets folder.

Parameters

None.

Category

HTML Filters

Description

The asset_url filter allows you to link up theme assets within your theme’s assets folder in your layouts and content templates.

When you push your theme to Live Editor’s servers, your theme’s assets are published to a content delivery network (CDN) for maximum performance. The final location within the CDN is assigned dynamically and is unguessable for anyone as a theme developer.

      <link href="{{ 'images/icons/favicon.ico' | asset_url }}" rel="shortcut icon">
      

You’ll often chain the asset_url with other HTML filters like img_tag, script_tag, and stylesheet_tag. It is important that you run the asset_url filter first before passing it to one of the other HTML filters.

      <head>
        {{ 'styles/site.min.css' | asset_url | stylesheet_tag }}
        {{ 'js/init.min.js' | asset_url | script_tag }}
      </head>