Getting Meta Tags on Views in Drupal 7
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
Actually, there is a sandbox module for that :
http://drupal.org/sandbox/ribakker/1356928
@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.
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.
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),.
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.
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!
Can I create a custom meta-tag like State or City using the Metatag module?
@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.
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.
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.
Good reminder, Derek.
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.
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.
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...
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..
Agreed! Thanks to the commenting community for sharing your wisdom.
Add metadata via contexts: https://drupal.org/project/context_metadata
I can think of several cases where that would come in handy. Thanks for linking!
Meta tags module and context meta data are the best combo currently by far. So much easier than anything else!