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)