Nofollow for Links in Shop-Sidebar
-
Hi! I am using Botiga for a few weeks now and after going live with the website I noticed the google web crawler bringing heavy load to my website. I am speaking of a website with 150 pages according to the sitemap and 30.000 different URLs crawled by google per day! What happend?
I use the Shop Sidebar with a lot of widgets of type “Botiga – Filter products by attribute”. Each widget creates links to the shop-page with the filters as URL-parameters of type
/shop/?filter_xxx=yyy&query_type=or&filter_zzz=aaa
. With more then ten filterable attributes in the sidebar, the combination leads to thousands of different links.I solved the issue with a script that adds
rel="nofollow"
to all links with url parameters.Question: Is there any other solution directly integrated in Botiga?
Here is the code I used (credits to perplexity.ai):
function add_nofollow_to_parameterized_links() {
?>
<script>
document.addEventListener('DOMContentLoaded', function() {
var links = document.getElementsByTagName('a');
for (var i = 0; i < links.length; i++) {
if (links[i].href.indexOf('?') > -1) {
links[i].classList.add('url-parameter-link');
}
}
});
jQuery(document).ready(function($) {
$('.url-parameter-link').attr('rel', 'nofollow');
});
</script>
<?php
}
add_action('wp_footer', 'add_nofollow_to_parameterized_links');
- You must be logged in to reply to this topic.