문제

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