Skip to content

Blocking one specific category for robots – Magento 2.2.11

I want to set robots: noindex, nofollow for 1 specific category.
I thought I just add a line in a source code like:

if (stripos($categoryName, ‘MyCategoryName’) !== false) {
$this->layoutFactory->setRobots(‘NOINDEX,NOFOLLOW’);

but I cannot locate the source code file, where the function for reading robots configuration from admin panel is.

Does anyone knows, where the file is? Or is there a better solution to make this work?

There are some topics here, but none says where the source code file is located.

Best regards,

Chris