There are some occasions when developing a new Responsive Website Design (RWD) for mobile devices is not possible due to cost and a revised solution is required. Sometimes you’ll want to serve the content dynamically based on the user’s device instead.

In addition to several RWD projects that I’ve worked in in recent years, I’ve also been asked to create dedicated mobile sites that are served when visitors arrive from a mobile device. (Whilst the RWD site was technically possible, the time consuming nature of the conversion would mean the costs would out-weigh the benefits).

Google doesn’t recommend this, but does support it, so to ensure that your SEO rankings are not penalised for providing different content you need to vary the HTTP header for the Googlebot.

According to Google: The Vary HTTP header has two important and useful implications:

  1. It signals to caching servers used in ISPs and elsewhere that they should consider the user agent when deciding whether to serve the page from cache or not. Without the Vary HTTP header, a cache may mistakenly serve mobile users the cache of the desktop HTML page or vice versa.
  2. It helps Google find your mobile-optimized content faster, as a valid Vary HTTP header is one of the signals we may use to crawl URLs that serve mobile-optimized content.

The website in question runs on WordPress and was using a custom theme activated using the Any Mobile Theme plugin. For desktop users and large tablets, the desktop site was served and for all others; the mobile site. The major difference was a removal of non-revenue generating material that was fixed width (iframes to external sites) that has previously been activated using page templates.

So to send the request using WordPress you need to:

  1. Open the functions.php file of both themes
  2. Add this code to each

function add_vary_header($headers) {
$headers['Vary'] = 'User-Agent';
return $headers;
}
add_filter('wp_headers', 'add_vary_header');

Adding the code will allow the Googlebot to be advised that it should send the mobile Googlebot round for the party too. If you are not using WordPress, a different method will be required. Find out more about the procedure at Google. This can also be added to RWD sites that hide significant portions of content.

Thanks to HetArena for the help on this one.

Comments are closed.