How to create metatags for pages resulting of Views module?

#32 metatag-n1804356-32.patch10.74 KBDamienMcKenna
PASSED: [[SimpleTest]]: [MySQL] 21 pass(es). View
#31 metatag-n1804356-31.patch0 bytesDamienMcKenna
PASSED: [[SimpleTest]]: [MySQL] 21 pass(es). View
#22 metatag-n1804356-22.patch10.76 KBDamienMcKenna
PASSED: [[SimpleTest]]: [MySQL] 21 pass(es). View
Members fund testing for the Drupal project. Drupal Association Learn more


couturier’s picture

Status: Active » Closed (duplicate)

You have to add a token to show each page. This can be done in Global settings. See this issue:

sahuni’s picture

Status: Closed (duplicate) » Active

Sorry, but your reply does not help me.
What are those Global Settings you're speaking of? from Views module? from Metatags module?
I looked long for each module but could not get a clue.

couturier’s picture

  • Install the Meta Tags module
  • Enable the Meta Tags module on the modules page
  • Go to Configuration
  • Click on Meta Tags - Configure Meta Tag defaults
  • Click Global
  • Click Edit
  • Add this to your title: [current-page:page-number]
  • Clear your Drupal caches under Configuration - Performance
  • Clear all your browser caches
  • Check your View Source to see the changes
  • If it does not work, make sure you have the latest dev version of Meta Tags installed, not the regular one. It has to be the dev for this to work at this time.
  • Please close this issue when you have found your solution. This is an exact duplicate of the link above.
couturier’s picture

New update: work is going on today about this issue at

Be sure to read that, because some changes are happening.

sahuni’s picture

Thanks Couturier for your help.

Problem is that you are speaking only of title metatag.
I'd like to add all the metatags to a view, same as for a node : it means description and keywords metatags. Is not it possible?

DamienMcKenna’s picture

Title: Views metatags » Views integration: option to add meta tags within the Views UI

@Sahuni: It depends on what you want to do:

What I'd really like to do is merge Dave's sandbox into the main module.

DamienMcKenna’s picture

Component: User interface » Code
sahuni’s picture

I don't use context module and I think it's too a big module to add. I have less than 10 views.
I'm not use to play with sanboxes and git, so not a welcome solution
in the French forum, someone said to use Seems odd.

Perhaps, I'll add metatags with code in preprocess treatment (I did that in D6).

But it would be fine to have a real possibility to have good SEO for views, with help of user interface.

alexweber’s picture

The code here works pretty well, should help until this gets worked on:

RollWhisTler’s picture

Git Noob here... i get an empty master branch there... how can i download the source from a branch?

DamienMcKenna’s picture

@RollWhiTler: You probably just followed the instructions on the project's main page, right? You need to grab the 7.x-1.x branch:

git clone --recursive --branch 7.x-1.x views_metatags

Randy74158’s picture

Hmm, this looks very complex to me. Maybe I will wait until it will be implemented to module.

aidanlis’s picture

Is there support coming for ?

couturier’s picture

@aidanlis That project is over a year old, and since then, Views has moved to core for D8. It seems to me that since time is limited for support for Meta Tags itself, it would be hard to find someone to continue working on this project to integrate the same things you can currently do in Meta Tags into Views.

WiredEscape’s picture

How to create metatags for pages resulting of Views module?

Easiest solution is to create a block view and place block inside regular node. Then set metatags on the node.

sahuni’s picture

and @WiredEscape, what would be the easiest way to do that?

couturier’s picture

@sahuni Under Structure > Blocks > Configure > Show block on specific pages > Only the listed pages = Add your node URL there for the block

sahuni’s picture

Yes it's a good idea, thanks

Dave Reid’s picture

Version: 7.x-1.0-alpha8 » 7.x-1.x-dev
Category: support » feature is now up to date and will likely either be promoted to a full project or merged as a sub-module here.

DamienMcKenna’s picture

I'd definitely vote to add it as a submodule, similar to metatag_context. I also would recommend renaming the module to "metatag_views" to keep the naming consistent with other submodules.

hass’s picture


DamienMcKenna’s picture

Status: Active » Needs review
10.76 KB
PASSED: [[SimpleTest]]: [MySQL] 21 pass(es). View

Here's Dave's code from the sandbox renamed as metatag_views and provided as a submodule.

alexweber’s picture

Status: Needs review » Reviewed & tested by the community

I've been rolling with the sandbox code for a while now and it works as advertised!

DamienMcKenna’s picture

Status: Reviewed & tested by the community » Needs review

This patch needs a bit more testing.

Dave Reid’s picture

Needs to test:

  • Removing metatag_views.install. The extender should be enabled by default due to 'enabled' => TRUE being set in it's definition.
  • metatag_views_page_alter should possibly use metatag_page_set_metatags()?
  • Should a default configuration for Views be enabled by default?
agoradesign’s picture

Hi Dave,
I've revealed a problem: the current code only works with the default configuration, overrides will always be ignored.

The reason is, that the function call to metatag_metatags_view() does not provide a language code inside the $metatags array. It's directly starting with the keyed meta tags. But metatag_metatags_view() is expecting a language code as key in the top level of the array. Otherwise nothing will be found, and the default configuration for Views will be used.

I think, that a solution for this problem would perfectly accompany with fixing the missing translation support (see

PS: I should have mentioned that I'm using the latest dev of metatag including the Entity Translation related patch from But when I look into the code of beta2, I can see, that it wouldn't work with that version either

Fred8’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta4

I have also around 10 Views generated pages that were lacking META-s. I solved this by using Simple Meta module. This module allows 3 basic tags to be overruled: Title, Description and keywords. I actually only use the first two.

So, now I have 2 META modules working together: the regular Meta Tags module that is used for nodes, and Simple Meta for Views pages. Whenever I need to edit Views META-s, I switch its special tab on, it appears at the left side of the screen, then I navigate to the page, click on the tab, edit it, and Save. After doing so, I disable the tab, as it's a little annoying, even though visible only to administrators.

Chris Burge’s picture

I am able to replicate the behavior @agoradesign describes.

  1. Create a new view
  2. Override default meta tag settings by checking 'Prevent search engines from indexing this page' box under advanced settings.
  3. Save the view and visit the page
  4. '<meta content="noindex" name="robots">' should render in the page header but does not.
Chris Burge’s picture

In the interim, Views PHP offers a solution for this issue by way of the 'drupal_add_html_head' function.

  1. Install and enable Views PHP.
  2. Add a 'Global: PHP' element to the View header.
  3. Insert the code below, customized for your use:
  $element = array(
    '#tag' => 'meta',
    '#attributes' => array(
      'name' => 'robots',
      'content' => 'noindex',
drupal_add_html_head($element, 'robots_noindex');

In the long-term, a reworked patch from #22 #1804356-22: Views integration: option to add meta tags within the Views UI is a better solution; however, the code immediately above will work in the mean time,

hass’s picture

Version: 7.x-1.0-beta4 » 7.x-1.x-dev
DamienMcKenna’s picture

0 bytes
PASSED: [[SimpleTest]]: [MySQL] 21 pass(es). View

This fixes the issue that agoradesign mentions in #26 so it's now possible to actually override the values on each View.

DamienMcKenna’s picture

10.74 KB
PASSED: [[SimpleTest]]: [MySQL] 21 pass(es). View


DamienMcKenna’s picture

Status: Needs review » Fixed

COMMITTED!!! Thanks Dave!!!

All follow-up work should be in new issues.

DamienMcKenna’s picture

Status: Fixed » Closed (fixed)

1.0-beta6 is out, so I'm closing this issue in the interest of keeping the issue queue clean.