Add REL = nofollow on collection pages for filter tag links in sidebar

LightingStyle
New Member
3 0 0

Hello,

I am looking for a solution to add rel = "nofollow" to the links in the sidebar filter on my collection pages. I've looked through the documentation on here but there doesn't appear to be a solution that will work for my theme.

I'm pretty sure I've located the code which is responsible for adding the link for the filtered collection page. I've tried pasting rel="nofollow" in several places but nothing seems to work. I'm assuming it would need to be added somewhere near one of the 'href' parts?

 <li class="level-1{%if line_collection.links.size > 0%} level-1-has-child{%endif%}{% if line_collection.active %} current-cat showAny{% endif %}{%if forloop.first%} opened{%endif%}">
          <a class="custom-control custom-checkbox"{% if line_collection.active %} href="javascript&colon;void(0)"{%else%} href="{{line_collection.url|default: 'javascript&colon;void(0)'}}" {% endif %}>
            <span class="custom-control-label">{{line_collection.title}}</span>
            {%- if line_collection.type == 'collection_link' -%}
            <span class="count lazyload" data-include="{{line_collection.url}}?view=count_with_tag">{{line_collection.object.all_products_count}}</span>
            {%- endif -%}
          </a>
          {% if line_collection.links.size > 0-%}
          <ul class="child_collection"{%unless forloop.first%} style="display: none" {%endunless%}>
            {% for child_link in line_collection.links-%}
              <li class="level-2{% if child_link.active %} current-cat{% endif %}">
                <a class="custom-control custom-checkbox"{% if child_link.active %} href="javascript&colon;void(0)"{%else%} href="{{child_link.url|default: 'javascript&colon;void(0)'}}"{% endif %}>
                  <span class="custom-control-label">{{child_link.title}}</span>
                  {%- if child_link.type == 'collection_link' -%}
                  <span class="count lazyload" data-include="{{child_link.url}}?view=count_with_tag">{{child_link.object.all_products_count}}</span>
                  {%- endif -%}
                </a>
              </li>
            {%- endfor -%}

 

When I inspect the page and hover over the filter tags, I can see the code responsible for the href link and as you can see there is no rel="nofollow"

LightingStyle_0-1613827108529.png

Hoping someone can help!

 

Thanks,

James

0 Likes
KieranR
Shopify Partner
234 21 64

I'd add in here and see what it does. 

https://www.diffchecker.com/k3RiYh8G 

If those side-bar link-lists get used for other stuff (not just tag links) you may not want to no-follow them all and setup a conditional in liquid to go if taglink then nofollow.

Full time Shopify SEO guy, based in NZ. Sometimes freelance outside the 9-5.
0 Likes
LightingStyle
New Member
3 0 0

Hey Kieran,

Thanks for your answer, really helpful. Appreciate your help.

I tried out the code you suggested, unfortunately it didn't seem to do anything. Just for some added context - in the sidebar there are 'category links' and then there are tag filter links underneath.

Here is an image to illustrate what we're trying to achieve:

 

LightingStyle_0-1613994116165.png

 

I may have sent you the code for the category list and not the actual tag filter links?

I've found some other possible bits of code that could be responsible for this. Do you think any of these could be responsible? (apologies in advance for the long message!) Thanks in advance

kt_filter_json.liquid

<script>
canonical_url = "{{canonical_url}}";
{%- unless collection -%}{% assign collection = collections['all'] %}{%- endunless -%}
collection.Crr = "{{collection.handle|default:'all'}}";
page.Han = "{{collection.handle|default:'all'}}";
currTags = {{current_tags | json}};
currTags_handleize = [{% for tag in current_tags %}{{tag|handleize|json}}{%-unless forloop.last-%},{%-endunless-%}{% endfor %}];
collectionTags = {{collection.all_tags|json}};
{%-if current_tags-%}
iscollectionTags = {{collection.tags|json}};
{%- else -%}
iscollectionTags = new Array;
{%- endif -%}
currPage = {{paginate.current_page}};
</script>
<script type="application/json" id="groupsFilters">
{"settings": {{section.settings | json}},"blocks": [{%- for block in section.blocks -%}{{block.settings | json}}{%-unless forloop.last-%},{%-endunless-%}{%- endfor -%}]}
</script>

kt_categories_sidebar.liquid

<div class="widget widget_product_categories{{prefix}}">
<div class="layered_subtitle_heading">
<span class="layered_subtitle">{{ 'blogs.sidebar.categories' | t }}<span></span></span>
<span class="ico"><i class="fkt-angle-down" aria-hidden="true"></i></span>
</div>
<ul class="product-categories kt_filterGroupItem_ul">
{%- if settings.list_categories_linklist == blank -%}
{%- for line_collection in collections -%}
{%- if line_collection.handle != 'wishlist' -%}
<li class="{% if collection.handle == line_collection.handle %} current-cat {% endif %}"><a data-scroll-top="" data-pjax-filter="" href="{{line_collection.url}}">{{line_collection.title}} <span class="count rtl_fix" data-ogr-title="({{line_collection.all_products_count}})">({{line_collection.all_products_count}})</span></a></li>
{%- endif -%}
{%- endfor -%}
{%- else -%}
{%- for line_collection in linklists[settings.list_categories_linklist].links -%}
{%- if line_collection.type == 'collection_link' -%}
<li class="level-1 {% if collection.handle == line_collection.object.handle %}current-cat showAny{% endif %}"><a data-scroll-top="" data-pjax-filter="" href="{{line_collection.object.url}}">{{line_collection.title}} <span class="count rtl_fix" data-ogr-title="({{line_collection.object.all_products_count}})">({{line_collection.object.all_products_count}})</span></a>
{%-assign child_links = linklists[line_collection.handle].links-%}
{% if child_links.size > 0-%}
<ul class="child_collection">
{% for child_link in child_links-%}
{%- if child_link.type == 'collection_link' -%}
<li class="level-2{% if collection.handle == child_link.object.handle %} current-cat{% endif %}"><a data-scroll-top="" data-pjax-filter="" href="{{child_link.object.url}}">{{child_link.title}} <span class="count rtl_fix" data-ogr-title="({{child_link.object.all_products_count}})">({{child_link.object.all_products_count}})</span></a></li>
{%- endif -%}
{%- endfor -%}
</ul>
{%- endif -%}
</li>
{%- endif -%}
{%- endfor -%}
{%- endif -%}
</ul>
</div>

collection_filter.liquid

<!-- collection-filter.liquid -->
{% assign view = cart.attributes.theme_coll_layout | split: '_' %}
{%-assign limit = settings.coll_limit -%}
{% if view.size == 2 %}
{%-assign limit = view[1] | replace: 'pds','' | plus: 0 -%}
{% endif %}
{%- unless collection.handle -%}
{%- assign collection = collections['all'] -%}
{%- endunless -%}
{%-paginate collection.products by limit %}
<div data-section-id="{{ section.id }}" data-section-type="collection-filter">
<div class="catalog-filter"><a data-pjax-filter class="ktjax d-none" href="javascript&colon;void(0)"></a></div>
{%-render 'kt_filter_json', paginate: paginate-%}
{%-assign typeBlocks = section.blocks | map: 'type'-%}
{%-if typeBlocks contains 'item_categories' -%}
<noscript class="kt_categories_filter">
<div class="widget widget_product_categories{{prefix}}{%if settings.list_categories_linklist == blank %} {{settings.coll_shop_layout}}-layout{%endif%}">
<div class="layered_subtitle_heading">
<span class="layered_subtitle">{{ 'collections.sidebar.categories' | t }}<span></span></span>
<span class="ico"><i class="fkt-angle-down" aria-hidden="true"></i></span>
</div>
<ul class="product-categories kt_filterGroupItem_ul">
{%- if settings.list_categories_linklist == blank -%}
{%- for line_collection in collections -%}
<li class="{% if line_collection.handle == collection.handle %}current-cat{% endif %}">
<a class="custom-control custom-checkbox"{% if line_collection.handle == collection.handle %} href="javascript&colon;void(0)"{%else%} href="{{line_collection.url|default: 'javascript&colon;void(0)'}}"{% endif %}>
<span class="custom-control-label">{{line_collection.title}}</span>
<span class="count">{{line_collection.all_products_count}}</span>
</a>
</li>
{%- endfor -%}
{%- else -%}
{%- assign list_categories_linklist = linklists[settings.list_categories_linklist].links -%}
{% comment %}
{%- for link in linklists[settings.list_categories_linklist].links -%}
{%- if link.links.size > 0 -%}
{%- assign handle_check = link.links | map: 'handle' -%}
{%- assign object_check = link.links | map: 'object' | map: 'id' -%}
{%- assign title_check = link.links | map: 'title' -%}
{%- if collection.id != blank and link.object.id == collection.id -%}
{%- assign list_categories_linklist = link.links -%}
{%-break-%}
{%- elsif handle_check contains collection.handle or title_check contains collection.title or object_check contains collection.id-%}
{%- assign list_categories_linklist = link.links -%}
{%-break-%}
{%- else -%}
{%- for child_link in link.links -%}
{%- if child_link.links.size > 0 -%}
{%- assign handle_check_ = child_link.links | map: 'handle' -%}
{%- assign object_check_ = child_link.links | map: 'object' | map: 'id' -%}
{%- assign title_check_ = child_link.links | map: 'title' -%}
{%- if child_link.object.id == collection.id -%}
{%- assign list_categories_linklist = link.links -%}
{%-break-%}
{%- elsif handle_check_ contains collection.handle or title_ contains collection.title or object_check_ contains collection.id-%}
{%- assign list_categories_linklist = child_link.links -%}
{%-break-%}
{%- else -%}
{%-continue-%}
{%- endif -%}
{%- else -%}
{%-continue-%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- else -%}
{%-continue-%}
{%- endif -%}
{%- endfor -%}
{%- if collection.id != blank -%}
{%- for link in list_categories_linklist -%}
{%- if link.object.id == collection.id and link.links.size > 0 -%}
{%- assign list_categories_linklist = link.links -%}
{%-break-%}
{%- else -%}
{%-continue-%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}{% endcomment %}
{%- for line_collection in list_categories_linklist -%}
<li class="level-1{%if line_collection.links.size > 0%} level-1-has-child{%endif%}{% if line_collection.active %} current-cat showAny{% endif %}{%if forloop.first%} opened{%endif%}">
<a class="custom-control custom-checkbox"{% if line_collection.active %} href="javascript&colon;void(0)"{%else%} href="{{line_collection.url|default: 'javascript&colon;void(0)'}}" {% endif %}>
<span class="custom-control-label">{{line_collection.title}}</span>
{%- if line_collection.type == 'collection_link' -%}
<span class="count lazyload" data-include="{{line_collection.url}}?view=count_with_tag">{{line_collection.object.all_products_count}}</span>
{%- endif -%}
</a>
{% if line_collection.links.size > 0-%}
<ul class="child_collection"{%unless forloop.first%} style="display: none" {%endunless%}>
{% for child_link in line_collection.links-%}
<li class="level-2{% if child_link.active %} current-cat{% endif %}">
<a class="custom-control custom-checkbox"{% if child_link.active %} href="javascript&colon;void(0)"{%else%} href="{{child_link.url|default: 'javascript&colon;void(0)'}}"{% endif %}>
<span class="custom-control-label">{{child_link.title}}</span>
{%- if child_link.type == 'collection_link' -%}
<span class="count lazyload" data-include="{{child_link.url}}?view=count_with_tag">{{child_link.object.all_products_count}}</span>
{%- endif -%}
</a>
</li>
{%- endfor -%}
</ul>
{%- endif -%}
</li>
{%- endfor -%}
{%- endif -%}
</ul>
</div>
</noscript>
{%-endif-%}
</div>
{% endpaginate -%}
{% schema %}

 

Any insight you have would be great, thanks again!

 

James

0 Likes
KieranR
Shopify Partner
234 21 64

Yeah sorry not sure I can add much more here, I'm not great at debugging from a longview like this.

Personally I'd go through a process like this:

  • Add a <!-- comment --> close to where you think it needs to be added
  • see where that appears in the source HTML
  • use a combo of devtools and HTML souce checking understand how the theme works
  • pinpoint exactly what piece of code is generating those href links
  • then throw a nofollow in like <a nofollow href="xyz">
  • test its working as expected
  • remove the debug comments tags

What's the actual end goal here though? Do you want to prevent the tag pages from appearing in Google SERPs?

Full time Shopify SEO guy, based in NZ. Sometimes freelance outside the 9-5.
0 Likes
LightingStyle
New Member
3 0 0

Hey Kieran,

No worries, thanks for the tips on debugging! I'll give that a try.

The end goal is to make sure the tagged URL's are not being crawled, indexed and ranked in the SERP. I've had trouble with this in the past with Shopify stores where the tagged pages create hundreds/thousands of duplicate pages that Google keeps discovering and it just ends up wasting our crawl budget and being really messy.

We'd much prefer to have fewer, higher quality pages, with their own unique meta data/titles/descriptions etc but we still need to use tags for user experience whilst shopping. So the workaround to this is to just target the 'tagged' keywords with new collection pages ("Gold wall lights" "Lights under £50" "LED Floor Lamps" etc). The 'nofollow' tag just helps to solidify to Google that these tagged URL's aren't important and we don't want them to be indexed.

Then, on the tagged pages we have a canonical rule set up. Something along the lines of (If URL includes 'tag', then canonical URL = the simplest version of the collection page). So when Google does crawl these tagged pages it knows not to try and index/rank them, instead it ranks the standard collection page.

It's a bit of effort initially to get it all set up but well worth it in the long run!

Thanks again for your help!

Cheers,

James

 

0 Likes
KieranR
Shopify Partner
234 21 64

Yeah tag pages are an issue, few ways to deal to them. But agree with this approach. 

Full time Shopify SEO guy, based in NZ. Sometimes freelance outside the 9-5.