Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Shopify SEO - attempt to avoid duplicate meta descriptions
Two changes to make in theme.liquid
It will add 'Page 2' etc to the meta description for collection/blog pages, to make those different.
It adds a canonical tag for tag-filtered pages, back to the base collection/blog page.
*** This is the standard meta description code: ***
{% if page_description %}
<meta name="description" content="{{ page_description | escape }}" />
{% endif %}
*** Completely replace it with: ***
{% if page_description %}
{% if template contains 'collection' and current_page != 1 %}
<meta name="description" content="Page {{ current_page }} - {{ page_description | escape }}" />
{% elsif template contains 'blog' and current_page != 1 %}
<meta name="description" content="Page {{ current_page }} - {{ page_description | escape }}" />
{% else %}
<meta name="description" content="{{ page_description | escape }}" />
{% endif %}
{% endif %}
*** This is the standard canonical tag code: ***
<link rel="canonical" href="{{ canonical_url }}" />
*** Completely replace it with this: ***
{% if template contains 'collection' and current_tags %}<meta name="robots" content="noindex" /> <link rel="canonical" href="{{ shop.url }}{{ collection.url }}" />
{% elsif template contains 'blog' and current_tags %}<meta name="robots" content="noindex" /> <link rel="canonical" href="{{ shop.url }}{{ blog.url }}" />
{% else %}<link rel="canonical" href="{{ canonical_url }}" /> {% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.