David Corbacho

Google +1 Button. The dilemma: Aliased or non aliased URLs

Some weeks ago I got a feature request in the Google Plus One module to use non aliased paths for node URLs. This is important for some users because they don't want to lose the counting in case they change the alias. It's now implemented as a non-default option in the admin settings of the module in the dev release (6.x and 7.x. branches).

Should you use alias or not in the Google Plus One Button? Let's see both sides of this dilemma:

Aliased node paths

The default setting (Aliased paths) of the Google +1 module will generate the URL with this call:

url('node/' . $nid, array('absolute' => TRUE));

Let's say for example that our node/8 has an aliased path page/test. Then, the Google +1 button markup will be:

<div data-href="http://drupalmotion.com/page/test" class="g-plusone"></div>

It doesn't matter if user is visiting the node page via /page/test or via node/8. The +1 button will be rendered always with the aliased path. Suppose that a user clicks the +1 button. In his profile you will see something like this:

The good about aliased path:

  • It's the same URL that user sees in its browser.
  • It's the URL present in the canonical tag in Drupal 7. (or in Drupal 6 if you are using NodeWords)
  • It's the URL that Google+ script will use if this module will be not installed.
  • Forget about problems of duplicated URLs
  • What if the user copy/paste the URL from the browser instead of using the button? Or uses the Chrome Extension, or other methods to share your page? You will have 2 countings for the same page.
  • You will see the friendly aliased paths in the Analytics reports and Google Webmaster pages.

The bad:

  • When you change the alias of the path, it will reset the counting. It doesn't matter that you use Pathauto to redirect from the old alias, or Global Redirect, or making a manual 301 redirection. The +1 are tied up to the original URL. You will have to deal with it.

Non-Aliased paths

So if you choose in the admin settings non aliased paths for the Google+1 button, it will generate this markup:

<div data-href="http://drupalmotion.com/node/8" class="g-plusone"></div>

The good:

  • This URL will be generated always, it doesn't matter if you are visiting the /node/8 or /page/test path.
  • You can change the alias and won't affect to the Google+1 button.

The bad:

  • In Drupal 7 the canonical tag is pointing to the aliased path, I don't know how this can affect for SEO.
  • If Google has not detected already, now it will be obvious for Google that you have duplicated URLs for node paths. The solution is to install Global Redirect in Drupal 6 and/or Redirect in Drupal 7. Be aware that you could have some issues with these modules when they are used with i18n.
  • Users will experience a short delay when visiting your site because the redirection that Global Redirect does to the aliased path.
  • In the edge case that for some reason you migrate your nodes to other site and their node ids change, it could be a mess.
  • I don't like that users see the node ids. They will be visible for example, when hovering the link in Google+.
  • In Google Webmaster reports and Google Analytics (Social Pages) it will be shown the node/8 paths. Not very useful when analyzing your traffic.
  • Matt from Google confirmed that with each 301 redirection there is a ‘little bit’ of google juice (Pagerank) that will evaporate. He states that 301 redirections should be used only when necessary.

Not using the module at all.

Some people have asked me: Why to use this module instead of copy/paste the script from Google in the tpl.php?

  • If you do so, you are letting the Google script decide for you the URL of the page. Whatever is in the URL in that moment in the browser: an anchor #section2, extra parameters ?utm_source=blabla, etc will be taken into account. So you are not controlling the URL, making the google button counting not be so reliable. In Drupal 7 the canonical tag helps with this problem.
  • If you have a multilingual site, the module will help you to generate the right language for the button depending of the site's language.
  • With the module you can manage the button settings easily from an admin page.
  • Any other case, you don't need the module if you want to use it directly in your themes.


As you see, there is no easy solution for this dilemma.

But I think the best approach is to offer by default aliased node paths, so you avoid problems with Duplicated URLs and there is no need for extra modules. If you are aware of the cons of using non-aliased paths, go for it. You have the option to do it from the admin settings.