0

I want to change the meta robots tag value from index,follow to noindex,nofollow to all category filter pages only. How can I achieve this?

I am trying to do this by jquery below-

<script type="text/javascript">
     var getCurrentUrl = window.location.href;
    if(getCurrentUrl.includes("?")){
    document.getElementsByTagName('meta')["robots"].content="INDEX,NOFOLLOW" ;

    }

</script>

But it's not updating the value of current meta robots tag.

1 Answer 1

0

There is one more way you can try like check if the current route is category and if the parameters is set or not and based on those condition you can change the meta tags, or, if you prefer using an JS then try the following code.

function urlParam(name){
    var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
    return results[1] || 0;
}
document.observe("dom:loaded", function() {
    if(urlParam('cat')) {
        //process your code
    }
});
1
  • Thanks, but above solution is not working.
    – chanchal
    Nov 29, 2019 at 4:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.