Getting Meta Tags on Views in Drupal 7

Posted by Art Williams on May 09, 2012

Meta elements are an important part of any SEO and even Social Media strategy for a website. Drupal has a number of excellent modules for adding meta tags to nodes, but Views integration is lacking. To add meta tags to a view in Drupal 7 there are two meta tag modules and many hurdles to implementation.

Meta Tags Quick Module

The Meta tags quick module has the ability to assign meta values based on a path. So once you have your view set up you can navigate to the Meta tags quick module settings (admin/config/search/metatags_quick/path_based) and create a path-based meta tag for that view page.

At first glance this may seem like the simplest solution. But when we’ve used this module on a site it adds tabs to the views that say “Path-Based Metatags.” This is confusing for clients and many times breaks the clean look of the page (especially on a homepage) when there are no other tabs on the view.

The second issue we’ve found with Meta tags quick is that it is built on the Fields API. We saw this as a benefit initially, but in practice it is cumbersome. It requires setting up metatags on each and every content type when most of the time we want consistent meta attributes across all the content of the site. Plus if you ever try to remove Meta tags quick it takes some time since the fields it creates are left on the content types and have to be removed manually before the module can be uninstalled.

Lastly, in our opinion, the Meta tags quick module requires two additional modules to complete its meta features. The first is Page Title which adds the <title> tag to a page’s HTML. The second is the Open Graph meta tags module which adds opengraph style tags in the <head> of a page.

Aside: Open Graph tags, while not as well known, are critically important in the world of social media sharing. If you have a Facebook Share button on your blog post without Open Graph tags, you are leaving to chance the items that get sent to Facebook when that Share button is pressed. With Open Graph tags you can send the correct image, title, and description to Facebook.

Metatag Module

Metatag module is the successor to Nodewords in Drupal 6, and is designed to be the ultimate metatags module for Drupal 7. In its current state it already includes Page Title and Open Graph tags. The only necessary feature absent from this module is Views integration. Despite this missing piece we prefer Metatag over Meta tags quick because of its complete feature set and lack of dependence on the Fields API.

Make Every Page a Node

The workaround to the missing Views Integration in the Metatag module is to make every page on your site a node, then add any view as a block under the node.

For example, we commonly need a view to display a list of teasers for articles on a page. If you make the view a block and place it in the main content region under a node called “Articles,” you can add your meta tags to the node and not be concerned at all with the view’s meta tags.

A fringe benefit of this approach from the site builder standpoint is that breadcrumbs, menus, and pathauto all become easier to set up and work more consistently when every page is a node.

For the client, this approach makes more sense because the top textual area of all pages (including views) is now easily and consistently editable.

The caveat—and it can be big—is when a view has an exposed filter or a contextual filter that uses URL parameters to pass the values. It’s possible that this type of view won’t function correctly as a block without AJAX-ifying it, which prevents deep linking into the filters. This issue is so specific that we rarely run into it, but since it is a showstopper it needs to be mentioned. In those cases we just resort to using the Meta tags quick, Page Title, and Open Graph meta tags modules on the site.

Also worth mentioning is that there are two sandbox modules that claim to accomplish the goal of Views integration with Metatag. I haven’t had the opportunity try either and would hesitate to use them on a production site, but the fact that they exist makes me optimistic that the issue can be solved in short order.

If you have a solution of your own that works, or have an opinion about making every page a node, please chime in. We’d like to hear your thoughts and experience.

MONTHLY MARKETING INSIGHTS.

Get thought-provoking and actionable insights to improve how your firm makes a connection with your customers.

LEAVE A COMMENT

The content of this field is kept private and will not be shown publicly.

Plain text

  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
Submitted by Art Williams on Wed, 05/09/2012 - 3:21pm

@Bast: I did mention in the post that there are two sandbox modules that claim to integrate Metatag with Views, however, using a sandbox module on a production site should be approached with a healthy dose of caution.

Submitted by Whitingx on Thu, 05/10/2012 - 4:10am

Also worth noting that the Metatag module doesn't cleanly integrate with Panels but the Metatags_quick module does.

There is also a difference in how these two modules store the data in the database so, from experience, choosing the wrong module and having to export/import the meta data can cause problems.

Submitted by Jamie Giberti on Thu, 05/10/2012 - 5:41am

You should take a look at my module Simple Page Title (http://drupal.org/project/simple_page_title) which operates on the same premise (path based) and operates independently of the other screens to make life as easy as possible for SEO's. A similar approach could be taken for meta tags (and it's something I've been thinking about doing myself),.

Submitted by Justin on Thu, 05/10/2012 - 8:11am

Just thought I would say that I have used the ribakker sandbox module, and while I agree that you should always use caution when using a sandbox module, this one seems pretty good. I've used it without issue on two sites.

Submitted by Art Williams on Thu, 05/10/2012 - 9:12am

Thanks for the comments everyone!

@Whitingx: Good to know about the lack of Panels integrations with the Metatag module. Thanks! We don't use Panels much around here but that is really important for those who do.

@Justin: Excellent! It's good to hear from someone who has experience with the module. I had looked at David Reid's sandbox module, but there were some unresolved issues in the queue so I'm glad ribakker's sandbox module seems stable. Sure would be nice to get this into the Metatag module itself!

Submitted by Mike on Mon, 06/11/2012 - 9:44am

Can I create a custom meta-tag like State or City using the Metatag module?

Submitted by JD Collier on Mon, 06/11/2012 - 3:24pm

@Mike: You can create your own metatag using its API ... but I haven't done it before. I have done this with MetaTag Quick module and that was very simple ... just add it as a field.

Submitted by Justin on Wed, 06/13/2012 - 10:39am

Hey guys, I ran into an issue with the meta tags module, and I thought I would post that here.

The sandbox module is still fine, but the actual meta tags module locks up IE7/8 and IE9 loads drastically slow when you go to add content. So anytime I'm on a node/add/content_type page I get a slow script warning from IE.

Apparently it has something to do with the vertical tabs implementation (possibly, according to this thread: http://drupal.org/node/1361722 - which though it points to the problem did not fix the issue.

I'm using 7.x-1.0-alpha6 which contains the fix mentioned here.

I just wanted to put this out there. Maybe it will help someone along the way. And if anyone has experienced, or not experienced, anything similar then maybe you can give me a shout.

Submitted by Derek Watterson on Tue, 07/03/2012 - 10:43am

Page title can resolve issues of duplicate titles. You'll just want to be sure to configure the pager suffix field under the configuration page.

Submitted by Amy Peveto on Tue, 07/03/2012 - 11:14am

Good reminder, Derek.

Submitted by Uzi on Wed, 08/15/2012 - 2:25pm

Thanks for a great review of the options available. I am in the process of optimizing some of my sites and I do not like the idea of using the field API more that I have to. You suggestion of adding views as a block is certainly a good alternative.

Submitted by Amy Peveto on Wed, 08/15/2012 - 2:40pm

The "view as block" option is one that we like and use often. Drupal is really versatile, so there's always more than one way to skin the proverbial cat.

Submitted by Uzi Ashkenazi on Fri, 09/07/2012 - 3:37pm

Some nice review and interesting workaround for metatags and views. My only concern is that type of thinking is the reason why Drupal in on a fast track to obesity (if it is not already there).

I am not sure if this is even possible but would it be great to have a field on a content type that assign a view to the node? An autocomplete views reference field.

I can think of at least 5 module that won't be needed with such field...

Submitted by drupaltutorial.co.uk on Tue, 10/16/2012 - 2:03pm

I've got this problem at the moment for a client, was going to try the sandbox module but probably use a page and block.. to get round it thanks for all the comments its helped a lot..

Submitted by Amy Peveto on Tue, 10/16/2012 - 2:22pm

Agreed! Thanks to the commenting community for sharing your wisdom.

Submitted by Amy Peveto on Tue, 12/18/2012 - 10:04am

I can think of several cases where that would come in handy. Thanks for linking!

Submitted by Your Name on Wed, 12/19/2012 - 9:42pm

Meta tags module and context meta data are the best combo currently by far. So much easier than anything else!