How can I set robots :

<meta name="robots" content="NOINDEX,NOFOLLOW"/>

for layered navigation results in Magento 2?

I have searched the internet but there is no information to be found for this pretty important feature.

2 Answers 2


I had the same problem and I solved creating a new module with an Observer with this code

protected $request;
protected $stateFilter;
protected $layoutFactory;

public function __construct(
    \Magento\Framework\App\Request\Http $request,
    \Magento\Framework\View\Page\Config $layoutFactory
    \Magento\LayeredNavigation\Block\Navigation\State $stateFilter
) {
    $this->request = $request;
    $this->stateFilter = $stateFilter;
    $this->layoutFactory = $layoutFactory;

public function execute(Observer $observer) {
    $selectedFilters = $this->stateFilter->getActiveFilters();
    if(count($selectedFilters) > 0) {


can you please provide more of your patch such as which event, or provide the entire module. I don't have enough information to create a solution based on the information you provided. I had to create an answer because I am not allowed to comment.

Your Answer

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

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