5

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( array( '#tag' => 'meta', '#name' => 'desription', '#value' => $my_custom_description, ), 'description', ); } } 
1

1 Answer 1

2

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.