Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It has been recommended by an SEO consultant that for paginated pages the page number is included in the page title to avoid duplicated content. How do I achieve this?

I did this:

    function hook_pager_link($variables){
  $text = $variables['text'];
  $page_new = $variables['page_new'];
  $element = $variables['element'];
  $parameters = $variables['parameters'];
  $attributes = $variables['attributes'];

  $page = isset($_GET['page']) ? $_GET['page'] : '';
  if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
    $parameters['page'] = $new_page;

  $query = array();
  if (count($parameters)) {
    $query = drupal_get_query_parameters($parameters, array());
  if ($query_pager = pager_get_query_parameters()) {
    $query = array_merge($query, $query_pager);

  // Set each pager link title
  if (!isset($attributes['title'])) {
    static $titles = NULL;
    if (!isset($titles)) {
      $titles = array(
        t('« first') => t('Go to first page'),
        t('‹ previous') => t('Go to previous page'),
        t('next ›') => t('Go to next page'),
        t('last »') => t('Go to last page'),
    if (isset($titles[$text])) {
      $attributes['title'] = $titles[$text];
    elseif (is_numeric($text)) {
      $attributes['title'] = t('Go to page @number', array('@number' => $text));

  // @todo l() cannot be used here, since it adds an 'active' class based on the
  //   path only (which is always the current path for pager links). Apparently,
  //   none of the pager links is active at any time - but it should still be
  //   possible to use l() here.
  // @see http://drupal.org/node/1410574

  //put the pagination page number into the title tag
  $attributes['href'] = url($_GET['q'], array('query' => $query));
  //add page
  $page = t('page');
  $pattern = '/' . $page . ' \d/';
  $title = drupal_get_title();
  preg_match($pattern, $title, $matches);
    $new_title = $title . ' - ' .  t('page') . ' ' . ($page + 1);
  return '<a' . drupal_attributes($attributes) . '>' . check_plain($text) . '</a>';
share|improve this question

Have you investigated the Page Title module? It, among other things, features

Pagination Suffix: One of the things you may noticed about Drupal in terms of SEO is that whenever you go through a paged list of content, the page title never changes. Google Webmaster Tools will flag this up as a problem as you essentially have several different pages all being identified with the same page title. A new feature, introduced in Page Title 2.1, is the ability to append the page number as a suffix pattern. This means any URL which contains something like page=2 in the query string will also have an optional token pattern suffixed onto the end of it. Important: for this feature to work properly, you need to be running Token 1.12 or later.

share|improve this answer
This would be very useful I would imagine. – Andrew Welch Feb 6 '14 at 11:42

If you have to set other tags or configration related to SEO I suggest you Metatag module, that helps also with page title.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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