Adding a rel=”alternate” link in Drupal 7

When your site is not responsive, but serves a mobile version instead of the desktop one, it is recommended to add a rel=”alternate” link to the head part of your desktop site notifying search crawlers about the existence of a mobile version for this page.

A simple way to do this in your template.php file:

The code above is simply to show how to add the rel=”alternate” link in Drupal and doesn’t take into consideration the logic of constructing the mobile url based on the desktop url which is very site specific.

*It is also recommended to add a canonical link from the mobile page to the desktop version

Leave a Reply

Your email address will not be published. Required fields are marked *