Solved

Why is asset_url leading to 404 errors on Shopify?

Ultrabender
Excursionist
25 2 14

Hello,

Without my understanding why, I found myself full of 404s on my site (image, script, etc.)

I tried to find where the problem was coming from and found that the asset_url tag itself didn't seem to work, at least it didn't lead to my files. Here is an example :

In theme.liquid, I have this line:

 

{{ 'jquery.min.js' | asset_url | script_tag }}

 

When I display my theme, this is what I get:

 

<script src="//cdn.shopify.com/s/files/1/0097/4192/6485/t/27/assets/jquery.min.js?26017" type="text/javascript"></script>

 

Except that this leads, you will understand, to a 404.

I admit that I do not understand how this is possible and why all of a sudden it no longer works.

Is there a way to "regenerate" the asset_url, or something like that?

Thanks a lot.

Accepted Solution (1)

Ultrabender
Excursionist
25 2 14

This is an accepted solution.

While I was doing my tests, some asset URLs started to change, without me doing anything. t/27 became t/10 and the files were accessible again. But not all. Mind-blowing.

After tearing my hair out for a few hours. I solved the problem in the following way:

  1. I created a .zip file of my theme that no longer worked (the one with problem with asset_url) without changing any line of code
  2. I created a "new" theme from this .zip file. I published it.
  3. It works, no more 404 problem.

Hope this helps someone.

Thank you Shopify 🤷‍♂️

View solution in original post

Replies 3 (3)

Ultrabender
Excursionist
25 2 14

This is an accepted solution.

While I was doing my tests, some asset URLs started to change, without me doing anything. t/27 became t/10 and the files were accessible again. But not all. Mind-blowing.

After tearing my hair out for a few hours. I solved the problem in the following way:

  1. I created a .zip file of my theme that no longer worked (the one with problem with asset_url) without changing any line of code
  2. I created a "new" theme from this .zip file. I published it.
  3. It works, no more 404 problem.

Hope this helps someone.

Thank you Shopify 🤷‍♂️

GMarsack
Visitor
2 0 1

How can this be an accepted solution? This is a reproducible bug? One should not have to do these steps just to get an asset file to load properly.

_derek
Shopify Partner
1 0 0

Couldn't agree more. Is this a joke?