Metafields not showing correctly

Topic summary

A user encountered an issue where metafields for Dietary Preferences and Allergen Information displayed headings and bullet points but no actual text content in the Shopify Dawn theme. The metafields were configured using Shopify’s standard metafield/metaobject definitions with predetermined answers.

Problem identified:
The original Liquid code attempted to access values using preference.fields["label"], which was incorrect for the metafield structure being used.

Solution provided:
Multiple working code alternatives were shared, including:

  • Using metafield_text or metafield_tag filters
  • Accessing the label directly via preference.label or preference["label"] without the .fields property
  • Simplified loop structure: {% for preference in product.metafields.shopify.dietary-preferences.value %}

Resolution:
The user confirmed the corrected code worked successfully, resolving the display issue.

Summarized with AI on October 28. AI used: claude-sonnet-4-5-20250929.

This is what I get for the Dietary Preferences and Allergen Information for metafields under the DAWN theme.

These are already set up under Shopify with predetermined answers, but this is how it is showing when I preview (no words)

Have tried the assistant and we just go round and round with different coding and the problem isn’t fixed, tried support and apparently they arn’t trained in coding. So I’m stuck. I have two other fields I set up myself which are fine, its just these two. Thanks

Hey @Ellenarosemary ,

If the metafileds data not showing correctly in Shopify then there maybe a potential issue causing this. If did code for it then can you share it with me so that I take a look and make it error free so that it works well.

Waiting for your reply.

Thanks

Hard to tell – need to see your:

  • Metafield definition screenshot
  • liquid code you’re using to output them
  • preview link to the actual page

This is the code for dietary preferences and Allergen Information:

{% if product.metafields.shopify.dietary-preferences %}

Dietary Preferences

    {% for preference in product.metafields.shopify.dietary-preferences.value %}
  • {{ preference.fields["label"] }}
  • {% endfor %}
{% endif %}

{% if product.metafields.shopify.allergen-information %}

Allergen Information

    {% for allergen in product.metafields.shopify.allergen-information.value %}
  • {{ allergen.fields["label"] }}
  • {% endfor %}
{% endif %}

This gives the example as per my original post.

This is the code for the dietary preferences and allergen information:

{% if product.metafields.shopify.dietary-preferences %}

Dietary Preferences

    {% for preference in product.metafields.shopify.dietary-preferences.value %}
  • {{ preference.fields["label"] }}
  • {% endfor %}
{% endif %}

{% if product.metafields.shopify.allergen-information %}

Allergen Information

    {% for allergen in product.metafields.shopify.allergen-information.value %}
  • {{ allergen.fields["label"] }}
  • {% endfor %}
{% endif %}

Well, the fact that it outputs the title and a bunch of dots means that code sees the metafield, it’s a list type MF and code can see the values. However, code outputs nothing inside

  • tags and this is where screenshot of your MF definition (and metaobject definition, if your MF refers to metaobjects ) would be helpful.

  • Here is the first picture, hopefully this is what you are after. The dietery preferences are the same for allergens

    [Screenshot 2025-05-19 at 1.25.57 PM.png]

    [Screenshot 2025-05-19 at 1.27.32 PM.png]

    Not sure if it actually showed correctly.

    See below for the details as requested, thanks

    Not sure if it actually showed correctly.

    Ah, so this is standard MF/MO definitions.

    There are several ways to do it:

    {% assign mf = product.metafields.shopify.dietary-preferences %}
      {% if mf  %}
        
    
          {{ mf | metafield_text: field: 'label' }}
        
    
      {% endif  %}
    

    Screenshot 2025-05-20 at 5.29.45 PM.png

    Or:

    {% assign mf = product.metafields.shopify.dietary-preferences %}
      {% if mf  %}
        {{ mf | metafield_tag: field: 'label' }}
      {% endif  %}
    

    Or:

    {% assign mf = product.metafields.shopify.dietary-preferences %}
      {% if mf  %}
        {% for mo in mf.value %}
          
    
    {{ mo.label }} 
    
        {% endfor  %}
      {% endif  %}
    

    Your original code can be modified like this – it is very similar to the previous code. You can use either {{ preference.label }} or {{ preference[“label”] }}, not .fields needed:

    {% if product.metafields.shopify.dietary-preferences %}
      
      ### Dietary Preferences
      
        {% for preference in product.metafields.shopify.dietary-preferences.value %}
          - {{ preference["label"] }}
        {% endfor %}
      
    
      
    
    {% endif %}
    

    Or, this can be done like this:

    {% assign mf = product.metafields.shopify.dietary-preferences %}
      {% if mf  %}
        
          ### Dietary Preferences
          {{ mf | metafield_tag: field: 'label' }}
        
    
      {% endif  %}
    

    Thank you that worked perfectly