5 * Document all supported APIs.
9 * Provides a ability to integrate alternative routes with metatags.
11 * Return an entity when the given route/route parameters matches a certain
12 * entity. All metatags will be rendered on that page.
14 * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
17 * @return \Drupal\Core\Entity\EntityInterface|null
18 * Return an entity, if the route should use metatags.
20 function hook_metatag_route_entity(\Drupal\Core\Routing\RouteMatchInterface $route_match) {
21 if ($route_match->getRouteName() === 'example.test_route') {
22 if ($node = $route_match->getParameter('node')) {
29 * Alter the metatags for pages that are not of content entities.
31 * @param array $metatags
32 * The special metatags to be added to the page.
33 * @param array $context
34 * The context, containing the entity used for token replacements.
36 function hook_metatags_alter(array &$metatags, array $context) {
37 // Exclude metatags on frontpage.
38 if (\Drupal::service('path.matcher')->isFrontPage()) {