Optimizing a Drupal Site for SEO and Google PageSpeed

A great content management system (CMS), over 1 million users globally have used Drupal to build powerful websites on the Internet. However, to maximize the search engine optimization (SEO) of a website built with a CMS like Drupal, you must configure the site with the proper settings. Let’s look at the basic steps you should take to optimize a fresh install of Drupal.

Optimizing Drupal for SEO

Not very SEO friendly by default, Drupal requires website owners to install a set of third-party modules to improve its search optimization. In order to optimize Drupal for SEO, you should:

  • Start with Clean URLs and the Pathauto ModuleThese will give you the benefit of being able to control the use of keywords in each URL based on the title of the page.
  • Install and Configure the Metatag Module. You will need these for advanced configurations of HTML, Open Graph, Twitter Card, and Dublin Core metatags required for social media and SERPs.
  • Use Google PageSpeed to test the site. Follow the recommendations for webpage performance according to this framework to fine tune the Drupal site settings.
  • Use the Advanced Aggregation Module (AdvAgg). This module overrides Drupal’s core aggregation to compress CSS and JavaScript, providing more options to optimize for page speed.

By installing these modules and paying close attention to the configurations of settings, the Drupal core variable system can effectively generate complex metatag results for dynamic content without having to manually enter the information for every page. By installing advanced aggregation of CSS and JavaScript, Drupal pages will consistently score high results on Google PageSpeed tests.

Clean URLS

When installing Drupal 7, the CMS will automatically run a test to see if the server will support the use of Clean URLs. The main reason for this is to confirm that the “mod-rewrite” extension for Apache is available. Clean URLs will remove the “?q=” string that appears after the domain name on every Drupal page and also allow for further customization of URLs with keywords based on the page title using the Pathauto module. The use of keywords in the URL is considered a major factor of the Google PageRank algorithm for categorizing the content of pages of search engine result pages (SERPs).

 

Hint: Sites that fail the Clean URL test on shared hosting can typically correct this by adding “RewriteBase /” to the .htaccess file. For more information on this process, visit the Drupal.org Clean URL page.

 

The only difference with Drupal 8 is that Clean URLs are enabled by default in the installation process and there is no admin section to disable them. For more information on configuring a web server to use Clean URLs with Drupal 8, visit this overview page on Drupal.org. The important point with Clean URLs is that they are just the starting point for maximizing SEO performance on a Drupal site with Pathauto.

Configuring the Pathauto Module for SEO

The installation process for the Pathauto, Metatag, & AdvAgg modules is standard: download the files from Drupal.org, unpack the zip files, and upload them to the server in the sites/all/modules folder or use Drush to install them with the command line. Enable each module in the Drupal administration section and check the permissions. (Note: Metatags requires both the CTools & Token modules)

 

Hint: The Pathauto module can also be used to organize content for site programming, such as when placing dynamic blocks on a page according to content type.

 

There are only a few main values to consider with Pathauto, then the module will automatically translate the page titles of Drupal content into SEO friendly URLs which are keyword rich for content searches. Navigate to the Pathauto configuration section and review the default settings, replacing any of the program variables using keywords.

Configuring the Metatag Module

When using the Metatag module with Drupal 7 and 8, the most important settings relate to the page title, canonical URL, and description. These metatags determine what summary text will display for each page in the Google SERPs or other search engines. The page description can be the same for all pages on a site or set individually for each unique page. Because pages with a unique description will perform better in the SERPs, it is important to configure the description to be based on the teaser summary.

The Metatags module will integrate with Views and also allow for the custom setting of page descriptions according to content type. Best practice is to configure the page description for the homepage and main menu landing pages manually, then use Drupal systems variables to auto-write unique values for dynamic content. Use of the Dublin Core tags is considered optional. The module also allows for custom icons and favicons to be programmed through metatags for web apps and mobile.

Drupal & Google PageSpeed Tests

Google PageSpeed is a great way to test the performance of your Drupal website and to ensure that Google is happy with your site. After all, optimizing for SEO is primarily optimizing for Google!

Google’s PageSpeed requirements are related to factors that go beyond the use of metatags in HTML, and include the page load time, the amount of text below browser cut-off displays, mobile readiness factors, the compression of images, and the compression of both CSS and JavaScript. Dublin Core tags use advanced semantic information for library cataloging, while new metatags can also be used to control the icons that display with the website on mobile devices and the favicon of a webpage in browser tabs.

Some of the issues with Google PageSpeed tests relate to the server environment – for example, the response time of the DNS server and the web host. This is why it’s always important to choose a good drupal web host. InMotion Hosting comes highly recommended as a top Drupal web host on many review sites.

The main factors that Google PageSpeed tests for:

  • Time of the initial page load and server response time
  • Use of compression of HTML, CSS, and JavaScript
  • Prioritization of visible content on mobile devices and web browsers
  • Image compression (jpg/jpeg, png, gif)
  • The use of browser caching on web pages

You should also use Riot for better image compression of .jpg and .png images, which optimizes the files for page speed much better than Photoshop when saving image files for the web. For more advanced page caching than Drupal core provides, use the Views Content Cache module, Boost, or alternatively a solution with APC, Memcache, and Varnish.

Advanced CSS and JavaScript Aggregation

Use of the AdvAgg module with Drupal is standard and simple but contains a wide range of settings that can be combined to optimize CMS performance for Google PageSpeed. The AdvAgg module overrides the standard CSS and JavaScript aggregation in Drupal core and can be accessed through the “Performance” area of the CMS administration section.

The main sections of the AdvAgg Module contain the settings for:

  • CSS and JavaScript compression
  • Third party compression plugins
  • Experimental applications

Change these settings to see which combinations work best for the website pages by visiting the Google PageSpeed test again and using a feedback process to find the optimal combination.

Another option is to use the Speedy module to replace the Drupal core JavaScript files with optimally compressed versions of the files. Speedy will also work well with the AdvAgg module, but needs to be updated with every Drupal core version change.

Summary & Recommendations

Following the guidelines in this tutorial will create a Drupal site fully optimized for SEO with a lot of flexibility for further configuration. While some aspects of page speed will depend on the server environment, using advanced page caching, properly deploying CSS and JavaScript aggregation, and optimizing image files will significantly improve Google’s PageSpeed test scores. Using the page description metatags, keyword-driven page titles in the URL structure, and employing the various modules mentioned in this article will ensure optimal search engine optimization configuration for a site built with Drupal.

Guest Post by Jay Douglas of Howtogetonline.com