How to add Open Graph Tags in Custom Module detail page?
I think that you need this.

    /**
 * Alter the metatags for pages that are not of content entities.
 *
 * @param array $metatags
 *   The special metatags to be added to the page.
 * @param array $context
 *   The context, containing the entity used for token replacements.
 */
function hook_metatags_alter(array &amp;$metatags, array $context) {
  // Exclude metatags on frontpage.
  if (\Drupal::service('path.matcher')-&gt;isFrontPage()) {
    $metatags = NULL;
  }
}