How can I correctly fetch and update a logo file name in the header.liquid file?

Topic summary

A developer is attempting to dynamically update a logo in a Shopify theme’s header.liquid file based on API calls triggered by daily cronjobs. The logo filename and event date information are stored in shop-level metafields.

Current Issue:

  • The hardcoded logo filename logo_l_170_7fa7b6c1-ceee-46f4-a228-70876fb68fec.jpg is not rendering correctly
  • Only placeholder text appears on the site instead of the actual image
  • The problem appears to be with the line: src="{{ sourceLogoFile | file_img_url: 'medium' | img_tag: 'PMM Logo' }}"

Proposed Solution:
A respondent suggests constructing the full image URL by concatenating the Shopify CDN base URL with the filename:

  • Create a new variable: sourceLogoFileUrl = 'https://cdn.shopify.com/s/files/1/...' | append: sourceLogoFile
  • Replace the base URL placeholder with the actual store’s CDN path
  • Use this complete URL in the img tag’s src attribute

The discussion remains open as implementation details and verification are pending.

Summarized with AI on November 19. AI used: claude-sonnet-4-5-20250929.

In header.liquid file, I’m trying to update “src=” value to the one that I will pass with an API call on specific days. At the moment, I’m just testing it by hardcoding a logo file name. My comments at the top of the code will help you understand my broad requirement. But I’m seeking help with only fetching the file name "

logo_l_170_7fa7b6c1-ceee-46f4-a228-70876fb68fec.jpg**"** correctly and updating src at this line
src=“{{ sourceLogoFile | file_img_url: ‘medium’ | img_tag: ‘PMM Logo’ }}” Currently, I only see this "

" width=“180” alt=“Reflect Perfection”> on the site. Here is the link to the development theme - https://8p6isrqx8kjp6x96-4826759279.shopifypreview.com

I believe the issue is somewhere at this line

src=“{{ sourceLogoFile | file_img_url: ‘medium’ | img_tag: ‘PMM Logo’ }}” The way I am fetching the file image url is wrong. Please help me.

{% comment %}
      Automation of logo updating follows the steps below.
      1. A Cronjob on POMS/PMM server runs once a day.
      2. An API call is made to Shopify to pass logo tag and logo event date info.
      3. The passed data is stored in shop level metafields generated by the API.
      4. Fields are a. shop.metafields.pmm.logo_tag b. shop.metafields.pmm.logo_date_info
      5. Get full logo file name from Shopify file section based on the logo_tag meta field content.
      6. Concatenate logo to logo_tag
    {% endcomment %}
    {% assign sourceLogoFile = 'logo_l_170_7fa7b6c1-ceee-46f4-a228-70876fb68fec.jpg' %}
    {%- if shop.metafields.pmm.logo_tag != "normal" -%}
      {% assign sourceLogoTagUppercase = shop.metafields.pmm.logo_tag | upcase %}
      {%- assign sourceLogoFile = 'logo' | append: sourceLogoTagUppercase | append: '.png' -%}
      {%- assign eventDate = '' -%}
      {%- if shop.metafields.pmm.logo_date_info != "normal" -%}
        {%- assign eventDate = shop.metafields.pmm.logo_date_info -%}
      {%- endif -%}
    {%- endif -%}
    {%- capture header_logo -%}
      
        {%- if section.settings.logo != blank -%}
          {%- capture image_size -%}{{ section.settings.logo_max_width }}x{%- endcapture -%}

          
               

Logo Image file: {{ section.settings.logo }}

          {%- if use_transparent_header and section.settings.transparent_logo != blank -%}
            
          {%- endif -%}
        {%- else -%}
          {{ shop.name }}
        {%- endif -%}
      
    {%- endcapture -%}
1 Like

Hello @pramodraam

It seems that the code you provided is not generating the correct image URL for the logo. To fix the issue, you can modify the code as follows:

{%- assign sourceLogoFileUrl = 'https://cdn.shopify.com/s/files/1/...' | append: sourceLogoFile %}

{%- capture header_logo -%}

{%- if section.settings.logo != blank -%}
{%- capture image_size -%}{{ section.settings.logo_max_width }}x{%- endcapture -%}

Logo Image file: {{ section.settings.logo }}

{%- if use_transparent_header and section.settings.transparent_logo != blank -%}

{%- endif -%}
{%- else -%}
{{ shop.name }}
{%- endif -%}

{%- endcapture -%}

In this code, a new variable sourceLogoFileUrl is introduced, which is a concatenation of the base image URL (e.g., https://cdn.shopify.com/s/files/1/…) and the sourceLogoFile variable. Make sure to replace ‘https://cdn.shopify.com/s/files/1/…’ with the correct base image URL for your Shopify store.

By updating the code in this way, the src attribute of the tag should use the correct image URL for the logo.