Custom domain breaks metaobject file and URL field links in Shopify

I’m having trouble with my product documentation setup after adding a custom domain to my Shopify store. Everything was working perfectly before the domain change, but now the links won’t work even though they look correct in the browser inspector.

Here’s my current liquid code:

{% assign product_docs = product.metafields.custom.product_documentation.value %}
<section class="documentation-section page-width">
  <h2 class="section-title uppercase mb-4">Product Documentation</h2>
  {% for doc in product_docs %}
    <div class="document-item flex justify-between items-center">
      <div class="doc-title">
        <a href={{doc.external_url}} title="View {{doc.name}}">{{doc.name}}</a>
      </div>
      <div class="doc-download flex items-center">
        <a href={{doc.attachment | file_url}} target="_blank">Download PDF</a>
        <span class="file-info">({{doc.attachment_size}})</span>
      </div>
    </div>
  {% endfor %}
</section>

The rendered HTML shows the URLs are being generated correctly:

<div class="document-item flex justify-between items-center">
  <div class="doc-title">
    <a href="https://cdn.shopify.com/s/files/1/0123/4567/8901/files/product-manual.pdf?v=1234567890" title="View Product Manual">Product Manual</a>
  </div>
  <div class="doc-download flex items-center">
    <a href="//mystore.com/cdn/shop/files/product-manual.pdf?v=9876543210" target="_blank">Download PDF</a>
    <span class="file-info">(245.67 kB)</span>
  </div>
</div>

I’ve tried switching between file fields and URL fields in my metaobject definition, but the links still won’t work. Has anyone else experienced this issue after connecting a custom domain? What am I missing here?

Sounds like a CDN caching issue from your domain change. Had the same problem when I migrated my store - Shopify’s file URLs get stuck serving mixed protocols during transitions. You’ll need that quote fix mentioned above, but also try forcing HTTPS on your file URLs. Use | file_url: 'https' instead of just | file_url for those attachment links. Check your browser’s dev tools network tab too - click the broken links and see what status codes you’re getting. I was getting 301 redirects that wouldn’t resolve until I cleared the CDN cache through Shopify admin. Sometimes you just gotta wait 24-48 hours for DNS to fully propagate after setting up a custom domain.

Had this exact same issue last month when I switched to a custom domain. You’re missing quotes around the href attributes in your liquid code. When URLs have query parameters or special characters, browsers can’t parse them without proper quoting.

Change your anchor tags to:

<a href="{{doc.external_url}}" title="View {{doc.name}}">{{doc.name}}</a>

and

<a href="{{doc.attachment | file_url}}" target="_blank">Download PDF</a>

The custom domain change probably altered how Shopify generates file URLs with different parameters, exposing this syntax issue that was working by coincidence before. Once I added the quotes, my metaobject file links worked immediately - didn’t need to change any field types.

This looks like a protocol issue, not just missing quotes. Your file_url filter is creating protocol-relative URLs (//) instead of proper HTTPS URLs. Shopify does this when it’s confused about which protocol to use - happens a lot during custom domain transitions. Try forcing HTTPS in your liquid code: {{doc.attachment | file_url | replace: '//', 'https://'}} or fix your domain settings to enforce SSL properly. I ran into the same thing when my SSL cert wasn’t fully activated on the custom domain. The CDN served mixed content and browsers blocked it. Check your SSL status in Shopify admin under Online Store > Domains.

check ur shopify file settings - custom domains can mess up file permissions. same issue happened to me after switching domains. my file access got switched to private. go to settings > files and make sure ur PDFs are public, otherwise those CDN URLs won’t work no matter how u quote them.