I need to add rel=canonical meta tags to some views. There are a couple of sandbox modules for the metatag module but I'm looking for a more simple solution.

Couldn't I just use views_php and drupal_add_html_head()?

2 Answers 2


Try the Context Metadata module. It can add metadata to node and non-node pages. The following metadata tags can be set according to a context: Title, Description, Keywords and Canonical URL.


If you want to add meta tags to a view without adding or writing a module, you could just do this. Add a block with the following PHP code and set the block visibility that view only.

$element = array(
  '#tag' => 'meta', // The #tag is the html tag - <link />
  '#attributes' => array( // Set up an array of attributes inside the tag
    'name' => 'description', 
    'content' => 'Your view description.',
drupal_add_html_head($element, 'yourviewname_meta_desc');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.