1

I have some pages which are created by page callback functions. I'm using the metatag module. I'm on D7

I need to control the metatags output (specifically the description/og:description).

This documentation looks like it would have been useful, but is empty: https://www.drupal.org/docs/7/modules/metatag/howto-assign-meta-tags-to-specific-non-entity-pages-d7

Thanks.

  • 1
    Did you try Context + Metatag:Context? Metatag:Context allows assigning metatags using various context definitions including paths. – Kirill Shabunov Oct 3 '17 at 15:18
0

There's a hook for that.

function HOOK_outsourcing_metatag_metatags_view_alter(&$output, $instance, $options) {
    if (current_path() == 'matches/my/path') {

      $output['og:description']['#attached']['drupal_add_html_head'][0][0]['#value'] = 
        'My special value';
  }
}
0

metatags has its own submodule for this, just enable 'Metatag: Context (metatag_context)'

then it appears in 'Add reaction' as 'Metadata'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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