I'm trying to add a custom meta tag description for a custom module using the metatag module.

I tried this without success:

function mycustommodule_metatag_metatags_view_alter(&$output, $instance) {
  if ($instance == 'mycustom:entity') {
    $output['description']['#attached']['drupal_add_html_head'][0] = array(
        '#tag' => 'meta',
        '#name' => 'desription',
        '#value' => $my_custom_description,

1 Answer 1


Instead of directly altering the metatag, you might want to look into creating a custom token: As described in this article

This will give you more freedom and flexibility. Then you can just use that custom token in the backend of metatags and configure it for content types that you like.

/admin/config/search/metatags metatag page

If you however, still prefer to use the hook in the op, don't forget that those are cached, you will need to clear all caches before it might appear.

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.