This topic has come up once or twice, regarding what we should mark as noindex by default.
Several of our templates make use of this, but due to the way some things work with layers etc, the place to set the noindex directive is back in the controllers. This is fine, although not necessary convenient from an end users looking to change the default behavior.
Using the robot.txt file to block access to certain areas works, however it does NOT prevent google from showing those assets in search results should google find a link to that asset.
So I was thinking we could add a $context['noindex'] array, probably in the loadTheme jumbo, that sets noindex for many of the areas that don't really have a reason to be indexed .... as an example
$context['noindex'] = array('profile', 'search', 'calendar', 'memberlist', 'help', 'who', 'stats', 'login', 'reminder', 'register', 'verificationcode', 'contact');
Then in index.template update the existing line to be
// Please don't index these Mr Robot.
if (!empty($context['robot_no_index']) || (!empty($context['current_action']) && in_array($context['current_action'], $context['noindex'])))
echo '
<meta name="robots" content="noindex" />';
Thoughts?
/me likes!
Since in 1.1 we have a Theme class (actually two lol), it may be an option to have the array as attribute of the class and then have in $context just "no_index" = true/false
Something like:
protected $no_index_actions = array();
public function __construct()
{
...
$this->no_index_actions = array('profile', 'search', 'calendar', 'memberlist', 'help', 'who', 'stats', 'login', 'reminder', 'register', 'verificationcode', 'contact');
...
}
then:
public function setupThemeContext()
{
...
$context['robot_no_index'] = in_array($context['current_action'], $this->no_index_actions);
...
}
and finally in the template:
// Please don't index these Mr Robot.
if (!empty($context['robot_no_index']))
echo '
<meta name="robots" content="noindex" />';
This would still allow the theme to define additional no_indexes like:
public function __construct()
{
parent::__construct();
$this->no_index_actions[] = 'my_action';
}
Well, not a lot of advantages in the end, just one less index in context. xD
BTW I like the idea.
nods
Done ... on my local ... PR in a bit, moar stuff to add ;)
Are all those things really not interesting? Okay, I can definitely see why you wouldn't want profile stuff not randomly showing up, but if you search for something like "site:elkarte.net register" then I think it would be straightstrange if you didn't get any (particularly relevant) results. That is, I'd be more inclined to think in terms of a reason to not be indexed than having to come up with a reason why something should be indexed.
Edit: fixed an autocorrect typo.
The access to the various sections is generally regulated by permissions, but if a link is present (e.g. for profiles) and guests do not have permissions, the search engine will collect a series of pointless login forms.
The noindex would clean them up a bit at least. :)
Right, a lack of permissions for guests would be a reason for noindex.