Ще одна SEO проблема в Друпал, яка може витрачати краулінговий бюджет - посилання "Відповісти" в коментарях. За замовчуванням звичайно вони закриті навіть у дефолтному robots.txt Drupal, але мені здалося цього мало так як павуки все одно їх краулят, і потім додають у Google search console у вигляді видалених через блокування в роботсі.
47000 посилань на які пошуковий бот витратив свій "бюджет" і які тепер мозолять мені очі в консолі. Логічне додати до цих посилань атрибут "nofollow"
Для цього у функції function comment_links($comment, $node) приблизно в рядках 1055 та 1078 файлу /modules/comment/comment.module.php додаємо:
'attributes' => array('title' => t('reply'), 'rel' => 'nofollow'),
У результаті вид функції може бути таким:
function comment_links($comment, $node) {
$links = array();
if ($node->comment == COMMENT_NODE_OPEN) {
if (user_access('administer comments') && user_access('post comments')) {
$links['comment-delete'] = array(
'title' => t('delete'),
'href' => "comment/$comment->cid/delete",
'html' => TRUE,
);
$links['comment-edit'] = array(
'title' => t('edit'),
'href' => "comment/$comment->cid/edit",
'html' => TRUE,
);
$links['comment-reply'] = array(
'title' => t('reply'),
'href' => "comment/reply/$comment->nid/$comment->cid",
'html' => TRUE,
'attributes' => array('title' => t('reply'), 'rel' => 'nofollow'),
);
if ($comment->status == COMMENT_NOT_PUBLISHED) {
$links['comment-approve'] = array(
'title' => t('approve'),
'href' => "comment/$comment->cid/approve",
'html' => TRUE,
'query' => array('token' => drupal_get_token("comment/$comment->cid/approve")),
);
}
}
elseif (user_access('post comments')) {
if (comment_access('edit', $comment)) {
$links['comment-edit'] = array(
'title' => t('edit'),
'href' => "comment/$comment->cid/edit",
'html' => TRUE,
);
}
$links['comment-reply'] = array(
'title' => t('reply'),
'href' => "comment/reply/$comment->nid/$comment->cid",
'html' => TRUE,
'attributes' => array('title' => t('reply'), 'rel' => 'nofollow'),
);
}
else {
$links['comment_forbidden']['title'] = theme('comment_post_forbidden', array('node' => $node));
$links['comment_forbidden']['html'] = TRUE;
}
}
return $links;
}
Все, тепер нові reply посилання не будуть поповнювати ряди виключених у Search console
- 32 перегляди