Skip to content

Instantly share code, notes, and snippets.

@stephpolinar
Last active December 2, 2024 04:48
Show Gist options
  • Save stephpolinar/3eb3c0fc2ff3c8841a93d5101715622f to your computer and use it in GitHub Desktop.
Save stephpolinar/3eb3c0fc2ff3c8841a93d5101715622f to your computer and use it in GitHub Desktop.
Get full URL of current page (including queries). Then noindex URLs with 'pr_prod_strat'
<!-- To be placed on theme.liquid WITHIN <head> tags -->
<!-- No index product recommendation URLs =========================================================== -->
{%- capture contentForQuerystring -%}{{ content_for_header }}{%- endcapture -%}
{%- assign pageUrl = contentForQuerystring
| split: '"pageurl":"'
| last
| split: '"'
| first
| split: '.myshopify.com'
| last
| replace: '\/', '/'
| replace: '%20', ' '
| replace: '\u0026', '&'
-%}
{% capture finalurl %}https://{{ pageUrl }}{% endcapture %}
{% if finalurl contains 'pr_prod_strat' %}
<meta name="robots" content="noindex" />
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment