Skip to content

Commit

Permalink
Merge pull request #807 from GSA/806-canonical-url
Browse files Browse the repository at this point in the history
806 add canonical url link
  • Loading branch information
gchi25 authored Jan 23, 2024
2 parents 8224e04 + ccd22d8 commit 9467ce0
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ function usagov_benefit_finder_page_page_attachments_alter(array &$page) {
if ($node && $node->bundle() == "bears_life_event") {
if (\Drupal::routeMatch()->getRouteName() == 'entity.node.canonical') {
$page['#attached']['library'][] = 'usagov_benefit_finder_page/benefit_finder_app';
$url = $node->toUrl('canonical')->setAbsolute(TRUE);
$page['#attached']['html_head_link'][] = [
[
'rel' => 'canonical',
'href' => $url->toString(),
],
];
}
}
}
Expand Down

0 comments on commit 9467ce0

Please sign in to comment.