---
title: "asset_url"

doc_type: static
doc_category: static
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/docs/sline/filter/asset-url'
  md: 'https://developer.shopline.com/docs/sline/filter/asset-url.md'
---

# asset_url


    Returns the content delivery network (CDN) URL for a static asset of the theme. The filter supports both absolute and relative path resolution modes.

    



    
`filepath | asset_url()` returns a string.
    



    
        ## Required params

        
             `filepath` `string`\: The file path. The following path types are supported:

- Absolute path: References files under the theme's `public` directory. The passed value must exclude the `public` directory. For example, if you want to reference the `/public/a.js` file, pass `a.js`.
- Relative path: Resolves the asset path based on the location of the file where the expression resides. The passed value must start with a period, such as `./a.js` or `../one/test.js`.
        
    





    
## Examples

        
            ### Absolute path

            When the resource to be referenced is at `/public/a.js`, pass `a.js` to resolve the CDN URL.

            
```sline
{{ "a.js" | asset_url() }}
```
            

            
        
            ### Relative path

            If the file containing the expression is located at `sections/test/two/two.html`, and the resource to be referenced is at `sections/test/one/test.js`, pass `../one/test.js` to resolve the CDN URL.

            
```sline
{{ "../one/test.js" | asset_url() }}
```
            

            
        
    
