Pergunta

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.

Nenhuma solução correta

Outras dicas

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
    }
});
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top