Website Building » Shopify » What Is Asset_url in Shopify?

What Is Asset_url in Shopify?

Last updated on October 2, 2022 @ 4:38 am

The asset_url filter returns the URL of a particular asset. The asset can be specified by its handle, which is the name of the file without the extension. For example, if the asset’s handle is “logo”, and its extension is “.png”, then the asset’s URL would be:

http://your-shopify-domain.com/assets/logo.png

If you want to get the URL of an asset from a specific theme, you can use the theme’s asset scope. For example, if you’re using the “default” theme, you would use:

{{ ‘logo.png’ | asset_url }}

If you’re using a different theme, such as “my-theme”, you would use:

PRO TIP: If you are not familiar with Shopify, asset_url may refer to a URL of a file within your Shopify account. This file may be an image, Javascript file, or CSS file.

Shopify is a platform for businesses to create and manage their online stores. As such, it is important to be aware that any assets associated with your Shopify account (including the asset_url) can be accessed and edited by anyone with access to your account.

If you are not comfortable with someone having access to assets in your Shopify account, we recommend changing the asset_url to a private URL or removing the asset altogether.

{{ ‘logo.png’ | asset_url | replace: ‘//s3.amazonaws.com/cdn2.Shopify.com/’, ‘//my-theme.myShopify.com/’ }}

You can also get the URL of an asset from within a Liquid template using the following syntax:

{{ ‘logo.png’ | asset_url | prepend: ‘/themes/my-theme/assets/’ }}

Drew Clemente

Drew Clemente

Devops & Sysadmin engineer. I basically build infrastructure online.