Last active
March 22, 2021 16:50
-
-
Save willbroderick/b38852d7c87762cc4804cbef0cbdf45b to your computer and use it in GitHub Desktop.
Shopify SEO - attempt to avoid duplicate meta descriptions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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