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

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?

- {{line_collection.title}}
              {%- if line_collection.type == 'collection_link' -%}
              {{line_collection.object.all_products_count}}
              {%- endif -%}
          
            {% if line_collection.links.size > 0-%}
          

              {% for child_link in line_collection.links-%}
                - {{child_link.title}}
                      {%- if child_link.type == 'collection_link' -%}
                      {{child_link.object.all_products_count}}
                      {%- endif -%}
                
              
              {%- 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”

Hoping someone can help!

Thanks,

James

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.

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:

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 :slightly_smiling_face:

kt_filter_json.liquid


kt_categories_sidebar.liquid


{{ 'blogs.sidebar.categories' | t }}

{%- if settings.list_categories_linklist == blank -%}
{%- for line_collection in collections -%}
{%- if line_collection.handle != 'wishlist' -%}
- {{line_collection.title}} ({{line_collection.all_products_count}})

{%- endif -%}
{%- endfor -%}
{%- else -%}
{%- for line_collection in linklists[settings.list_categories_linklist].links -%}
{%- if line_collection.type == 'collection_link' -%}
- {{line_collection.title}} ({{line_collection.object.all_products_count}})
  {%-assign child_links = linklists[line_collection.handle].links-%}
  {% if child_links.size > 0-%}

  {% for child_link in child_links-%}
  {%- if child_link.type == 'collection_link' -%}
  - {{child_link.title}} ({{child_link.object.all_products_count}})
  {%- endif -%}
  {%- endfor -%}

  {%- endif -%}

{%- endif -%}
{%- endfor -%}
{%- endif -%}

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 %}

{%-render 'kt_filter_json', paginate: paginate-%}
{%-assign typeBlocks = section.blocks | map: 'type'-%}
{%-if typeBlocks contains 'item_categories' -%}

{%-endif-%}

{% endpaginate -%}
{% schema %}

Any insight you have would be great, thanks again! :slightly_smiling_face:

James

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 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?

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! :slightly_smiling_face:

Thanks again for your help!

Cheers,

James

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