Вопрос

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.

Нет правильного решения

Другие советы

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
    }
});
Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top