Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

ContentForHeaderModification

ContentForHeaderModification

AlissaWillow
Shopify Partner
5 0 1

I have seen the following used to capture and assign the query string to a variable for use in adding no index tags, however it doesn't pass the Shopify theme check.  Has anyone found a better solution?

{%- capture contentForQuerystring -%}{{ content_for_header }}{%- endcapture -%}
{%- assign pageUrl = contentForQuerystring | split: '"pageurl":"' | last | split: '"' | first | split: '.myshopify.com' | last |
         replace: '\/', '/' |
         replace: '%20', ' ' |
         replace: '\u0026', '&'
      -%}
{%- if pageUrl contains "?" -%}
          <meta name="robots" content="noindex">
{% elsif pageUrl contains "tagged" %}
          <meta name="robots" content="noindex">
{%- endif -%}


This is the error
error: ContentForHeaderModification: Do not rely on the content of `content_for_header`.
{%- capture contentForQuerystring -%}{{ content_for_header }}{%- endcapture -%}

More info: ContentForHeaderModification (shopify.dev)
Replies 0 (0)