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”
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.
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
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 -%}
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!